update the cookbook and role for swift
This commit is contained in:
parent
c944543a1f
commit
f2817eff86
@ -9,31 +9,31 @@
|
||||
"ref": "f759cd013c0a836f2acb219b3e006ff0a1308878"
|
||||
},
|
||||
"memcached": {
|
||||
"locked_version": "1.4.0"
|
||||
"locked_version": "1.6.2"
|
||||
},
|
||||
"runit": {
|
||||
"locked_version": "1.1.6"
|
||||
"locked_version": "1.3.0"
|
||||
},
|
||||
"build-essential": {
|
||||
"locked_version": "1.4.0"
|
||||
"locked_version": "1.4.2"
|
||||
},
|
||||
"yum": {
|
||||
"locked_version": "2.3.0"
|
||||
"locked_version": "2.4.0"
|
||||
},
|
||||
"sysctl": {
|
||||
"locked_version": "0.3.3"
|
||||
},
|
||||
"apt": {
|
||||
"locked_version": "2.1.0"
|
||||
"locked_version": "2.3.0"
|
||||
},
|
||||
"git": {
|
||||
"locked_version": "2.5.2"
|
||||
"locked_version": "2.7.0"
|
||||
},
|
||||
"dmg": {
|
||||
"locked_version": "1.1.0"
|
||||
"locked_version": "2.0.4"
|
||||
},
|
||||
"windows": {
|
||||
"locked_version": "1.10.0"
|
||||
"locked_version": "1.11.0"
|
||||
},
|
||||
"chef_handler": {
|
||||
"locked_version": "1.1.4"
|
||||
|
@ -0,0 +1,46 @@
|
||||
# CHANGELOG for cookbook-openstack-object-storage
|
||||
|
||||
This file is used to list changes made in each version of cookbook-openstack-object-storage.
|
||||
|
||||
## 7.1.0:
|
||||
* Update apt sources to grizzly to prepare for grizzly
|
||||
and havana branches
|
||||
|
||||
## 7.0.11:
|
||||
* Add missing swift-container-sync upstart service which is
|
||||
not setup by default in ubuntu 12.04 packages
|
||||
|
||||
## 7.0.10:
|
||||
* Do not role restrict super_admin_key in proxy config
|
||||
* Case correct swauth_version attribute in proxy recipe
|
||||
* Treat platform_options["swauth_packages"] as a list
|
||||
|
||||
## 7.0.9:
|
||||
* Bugfix tempurl role restriction
|
||||
|
||||
## 7.0.8:
|
||||
* Bugfix allow_override spacing in proxy server template
|
||||
|
||||
## 7.0.7:
|
||||
* Add flexibility to middleware pipeline
|
||||
|
||||
## 7.0.6:
|
||||
* Add choice of install python-swauth from git or package
|
||||
|
||||
## 7.0.5:
|
||||
* Add support for container-sync
|
||||
|
||||
## 7.0.4:
|
||||
* Allow roles used in searches to be defined by cookbook user
|
||||
|
||||
## 7.0.3:
|
||||
* Bugfix the swift-ring-builder output scanner
|
||||
|
||||
## 7.0.2:
|
||||
* Expand statsd support as well as capacity and recon supporting.
|
||||
|
||||
## 7.0.1:
|
||||
* Support more then 24 disks (/dev/sdaa, /dev/vdab, etc)
|
||||
|
||||
## 7.0.0:
|
||||
* Initial openstack object storage cookbook
|
@ -63,6 +63,14 @@ Attributes
|
||||
|
||||
* ```default[:swift][:authmode]``` - "swauth" or "keystone" (default "swauth"). Right now, only swauth is supported (defaults to swauth)
|
||||
|
||||
* ```default[:swift][:tempurl]``` - "true" or "false". Adds tempurl to the pipeline and sets allow_overrides to true when using swauth
|
||||
|
||||
* ```default[:swift][:swauth_source]``` - "git" or "package"(default). Selects between installing python-swauth from git or system package
|
||||
|
||||
* ```default[:swift][:swauth_repository]``` - Specifies git repo. Default "https://github.com/gholt/swauth.git"
|
||||
|
||||
* ```default[:swift][:swauth_version]``` - Specifies git repo tagged branch. Default "1.0.8"
|
||||
|
||||
* ```default[:swift][:swift_secret_databag_name]``` - this cookbook supports an optional secret databag where we will retrieve the following attributes overriding any default attributes below. (defaults to nil)
|
||||
|
||||
```
|
||||
@ -249,7 +257,7 @@ License and Author
|
||||
| | |
|
||||
|:---------------------|:---------------------------------------------------|
|
||||
| **Authors** | Alan Meadows (<alan.meadows@gmail.com>) |
|
||||
| | Oisin Feely (<of3434@att.com>) |
|
||||
| | Oisin Feeley (<of3434@att.com>) |
|
||||
| | Ron Pedde (<ron.pedde@rackspace.com>) |
|
||||
| | Will Kelly (<will.kelly@rackspace.com>) |
|
||||
| | |
|
||||
|
@ -11,7 +11,7 @@ default["swift"]["git_builder_ip"] = "127.0.0.1"
|
||||
|
||||
# the release only has any effect on ubuntu, and must be
|
||||
# a valid release on http://ubuntu-cloud.archive.canonical.com/ubuntu
|
||||
default["swift"]["release"] = "folsom"
|
||||
default["swift"]["release"] = "grizzly"
|
||||
|
||||
# we support an optional secret databag where we will retrieve the
|
||||
# following attributes overriding any default attributes here
|
||||
@ -25,6 +25,17 @@ default["swift"]["release"] = "folsom"
|
||||
# }
|
||||
default["swift"]["swift_secret_databag_name"] = nil
|
||||
|
||||
#--------------------
|
||||
# roles
|
||||
#--------------------
|
||||
|
||||
default["swift"]["setup_chef_role"] = "swift-setup"
|
||||
default["swift"]["management_server_chef_role"] = "swift-management-server"
|
||||
default["swift"]["proxy_server_chef_role"] = "swift-proxy-server"
|
||||
default["swift"]["object_server_chef_role"] = "swift-object-server"
|
||||
default["swift"]["account_server_chef_role"] = "swift-account-server"
|
||||
default["swift"]["container_server_chef_role"] = "swift-container-server"
|
||||
|
||||
#--------------------
|
||||
# authentication
|
||||
#--------------------
|
||||
@ -53,7 +64,40 @@ default["swift"]["ring"]["replicas"] = 3
|
||||
#------------------
|
||||
# statistics
|
||||
#------------------
|
||||
default["swift"]["enable_statistics"] = true
|
||||
default["swift"]["statistics"]["enabled"] = true
|
||||
default["swift"]["statistics"]["sample_rate"] = 1
|
||||
|
||||
# there are two ways to discover your graphite server ip for
|
||||
# statsd to periodically publish to. You can directly set
|
||||
# the ip below, or leave it set to nil and supply chef with
|
||||
# the role name of your graphite server and the interface
|
||||
# name to retrieve the appropriate internal ip address from
|
||||
#
|
||||
# if no servers with the role below can be found then
|
||||
# 127.0.0.1 will be used
|
||||
default["swift"]["statistics"]["graphing_ip"] = nil
|
||||
default["swift"]["statistics"]["graphing_role"] = 'graphite-role'
|
||||
default["swift"]["statistics"]["graphing_interface"] = 'eth0'
|
||||
|
||||
# how frequently to run chef instantiated /usr/local/bin/swift_statsd_publish.py
|
||||
# which publishes dispersion and recon statistics (in minutes)
|
||||
default["swift"]["statistics"]["report_frequency"] = 15
|
||||
|
||||
# enable or disable specific portions of generated report
|
||||
default["swift"]["statistics"]["enable_dispersion_report"] = true
|
||||
default["swift"]["statistics"]["enable_recon_report"] = true
|
||||
default["swift"]["statistics"]["enable_disk_report"] = true
|
||||
|
||||
# settings for statsd which should be configured to use the local
|
||||
# statsd daemon that chef will install if statistics are enabled
|
||||
default["swift"]["statistics"]["statsd_host"] = "127.0.0.1"
|
||||
default["swift"]["statistics"]["statsd_port"] = "8125"
|
||||
default["swift"]["statistics"]["statsd_prefix"] = "openstack.swift"
|
||||
|
||||
# paths to the recon cache files
|
||||
default["swift"]["statistics"]["recon_account_cache"] = "/var/cache/swift/account.recon"
|
||||
default["swift"]["statistics"]["recon_container_cache"] = "/var/cache/swift/container.recon"
|
||||
default["swift"]["statistics"]["recon_object_cache"] = "/var/cache/swift/object.recon"
|
||||
|
||||
#------------------
|
||||
# network settings
|
||||
@ -109,11 +153,52 @@ default["swift"]["disk_test_filter"] = [ "candidate =~ /(sd|hd|xvd|vd)(?!a$)[a-z
|
||||
"not system('/sbin/parted /dev/' + candidate + ' -s print | grep linux-swap')",
|
||||
"not info.has_key?('removable') or info['removable'] == 0.to_s" ]
|
||||
|
||||
#-------------------
|
||||
# template overrides
|
||||
#-------------------
|
||||
|
||||
# proxy-server
|
||||
|
||||
# override in a wrapper to enable tempurl with swauth
|
||||
default["swift"]["tempurl"]["enabled"] = false
|
||||
|
||||
# container-server
|
||||
|
||||
# Override this with an allowed list of your various swift clusters if you wish
|
||||
# to enable container sync for your end-users between clusters. This should
|
||||
# be an array of fqdn hostnames for the cluster end-points that your end-users
|
||||
# would access in the format of ['host1', 'host2', 'host3']
|
||||
default["swift"]["container-server"]["allowed_sync_hosts"] = []
|
||||
|
||||
# container-sync logging settings
|
||||
default["swift"]["container-server"]["container-sync"]["log_name"] = 'container-sync'
|
||||
default["swift"]["container-server"]["container-sync"]["log_facility"] = 'LOG_LOCAL0'
|
||||
default["swift"]["container-server"]["container-sync"]["log_level"] = 'INFO'
|
||||
|
||||
# If you need to use an HTTP Proxy, set it here; defaults to no proxy.
|
||||
default["swift"]["container-server"]["container-sync"]["sync_proxy"] = nil
|
||||
|
||||
# Will sync, at most, each container once per interval (in seconds)
|
||||
default["swift"]["container-server"]["container-sync"]["interval"] = 300
|
||||
|
||||
# Maximum amount of time to spend syncing each container per pass (in seconds)
|
||||
default["swift"]["container-server"]["container-sync"]["container_time"] = 60
|
||||
|
||||
#------------------
|
||||
# swauth source
|
||||
# -----------------
|
||||
# Versions of swauth in Ubuntu Cloud Archive PPA can be outdated. This
|
||||
# allows us to chose to install directly from a tagged branch of
|
||||
# gholt's repository.
|
||||
# values: package, git
|
||||
default["swift"]["swauth_source"] = "package"
|
||||
default["swift"]["swauth_repository"] = "https://github.com/gholt/swauth.git"
|
||||
default["swift"]["swauth_version"] = "1.0.8"
|
||||
|
||||
#------------------
|
||||
# packages
|
||||
#------------------
|
||||
|
||||
|
||||
# Leveling between distros
|
||||
case platform
|
||||
when "redhat"
|
||||
@ -132,7 +217,8 @@ when "redhat"
|
||||
"git_dir" => "/var/lib/git",
|
||||
"git_service" => "git",
|
||||
"service_provider" => Chef::Provider::Service::Redhat,
|
||||
"override_options" => ""
|
||||
"override_options" => "",
|
||||
"swift_statsd_publish" => "/usr/bin/swift-statsd-publish.py"
|
||||
}
|
||||
#
|
||||
# python-iso8601 is a missing dependency for swift.
|
||||
@ -153,7 +239,8 @@ when "centos"
|
||||
"git_dir" => "/var/lib/git",
|
||||
"git_service" => "git",
|
||||
"service_provider" => Chef::Provider::Service::Redhat,
|
||||
"override_options" => ""
|
||||
"override_options" => "",
|
||||
"swift_statsd_publish" => "/usr/bin/swift-statsd-publish.py"
|
||||
}
|
||||
when "fedora"
|
||||
default["swift"]["platform"] = {
|
||||
@ -171,7 +258,8 @@ when "fedora"
|
||||
"git_dir" => "/var/lib/git",
|
||||
"git_service" => "git",
|
||||
"service_provider" => Chef::Provider::Service::Systemd,
|
||||
"override_options" => ""
|
||||
"override_options" => "",
|
||||
"swift_statsd_publish" => "/usr/bin/swift-statsd-publish.py"
|
||||
}
|
||||
when "ubuntu"
|
||||
default["swift"]["platform"] = {
|
||||
@ -189,6 +277,7 @@ when "ubuntu"
|
||||
"git_dir" => "/var/cache/git",
|
||||
"git_service" => "git-daemon",
|
||||
"service_provider" => Chef::Provider::Service::Upstart,
|
||||
"override_options" => "-o Dpkg::Options:='--force-confold' -o Dpkg::Option:='--force-confdef'"
|
||||
"override_options" => "-o Dpkg::Options:='--force-confold' -o Dpkg::Option:='--force-confdef'",
|
||||
"swift_statsd_publish" => "/usr/local/bin/swift-statsd-publish.py"
|
||||
}
|
||||
end
|
||||
|
@ -0,0 +1,19 @@
|
||||
# swift-container-sync - SWIFT Container Sync
|
||||
#
|
||||
# The swift container sync.
|
||||
|
||||
description "SWIFT Container Sync"
|
||||
author "Sergio Rubio <rubiojr@bvox.net>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
pre-start script
|
||||
if [ -f "/etc/swift/container-server.conf" ]; then
|
||||
exec /usr/bin/swift-init container-sync start
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
end script
|
||||
|
||||
post-stop exec /usr/bin/swift-init container-sync stop
|
@ -3,7 +3,7 @@ maintainer "ATT, Inc."
|
||||
license "Apache 2.0"
|
||||
description "Installs and configures Openstack Swift"
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "1.1.0"
|
||||
version "7.1.0"
|
||||
recipe "openstack-object-storage::setup", "Does initial setup of a swift cluster"
|
||||
recipe "openstack-object-storage::account-server", "Installs the swift account server"
|
||||
recipe "openstack-object-storage::object-server", "Installs the swift object server"
|
||||
|
@ -62,7 +62,8 @@ def generate_script
|
||||
|
||||
# figure out what's present in the cluster
|
||||
disk_data[which] = {}
|
||||
disk_state,_,_ = Chef::Search::Query.new.search(:node,"chef_environment:#{node.chef_environment} AND roles:swift-#{which}-server")
|
||||
role = node["swift"]["#{which}_server_chef_role"]
|
||||
disk_state,_,_ = Chef::Search::Query.new.search(:node,"chef_environment:#{node.chef_environment} AND roles:#{role}")
|
||||
|
||||
# for a running track of available disks
|
||||
disk_data[:available] ||= {}
|
||||
@ -195,24 +196,24 @@ def parse_ring_output(ring_data)
|
||||
next
|
||||
elsif line =~ /^\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+)\s+(\S+)\s+([0-9.]+)\s+(\d+)\s+([-0-9.]+)\s*$/
|
||||
output[:hosts] ||= {}
|
||||
output[:hosts][$3] ||= {}
|
||||
output[:hosts][$4] ||= {}
|
||||
|
||||
output[:hosts][$3][$5] = {}
|
||||
output[:hosts][$4][$6] ||= {}
|
||||
|
||||
output[:hosts][$3][$5][:id] = $1
|
||||
output[:hosts][$3][$5][:region] = $2
|
||||
output[:hosts][$3][$5][:zone] = $3
|
||||
output[:hosts][$3][$5][:ip] = $4
|
||||
output[:hosts][$3][$5][:port] = $5
|
||||
output[:hosts][$3][$5][:device] = $6
|
||||
output[:hosts][$3][$5][:weight] = $7
|
||||
output[:hosts][$3][$5][:partitions] = $8
|
||||
output[:hosts][$3][$5][:balance] = $9
|
||||
output[:hosts][$4][$6][:id] = $1
|
||||
output[:hosts][$4][$6][:region] = $2
|
||||
output[:hosts][$4][$6][:zone] = $3
|
||||
output[:hosts][$4][$6][:ip] = $4
|
||||
output[:hosts][$4][$6][:port] = $5
|
||||
output[:hosts][$4][$6][:device] = $6
|
||||
output[:hosts][$4][$6][:weight] = $7
|
||||
output[:hosts][$4][$6][:partitions] = $8
|
||||
output[:hosts][$4][$6][:balance] = $9
|
||||
elsif line =~ /^\s+(\d+)\s+(\d+)\s+(\d+\.\d+\.\d+\.\d+)\s+(\d+)\s+(\S+)\s+([0-9.]+)\s+(\d+)\s+([-0-9.]+)\s*$/
|
||||
output[:hosts] ||= {}
|
||||
output[:hosts][$3] ||= {}
|
||||
|
||||
output[:hosts][$3][$5] = {}
|
||||
output[:hosts][$3][$5] ||= {}
|
||||
|
||||
output[:hosts][$3][$5][:id] = $1
|
||||
output[:hosts][$3][$5][:zone] = $2
|
||||
|
@ -23,11 +23,39 @@ end
|
||||
|
||||
include_recipe 'sysctl::default'
|
||||
|
||||
|
||||
#-------------
|
||||
# stats
|
||||
#-------------
|
||||
|
||||
# optionally statsd daemon for stats collection
|
||||
if node["swift"]["enable_statistics"]
|
||||
if node["swift"]["statistics"]["enabled"]
|
||||
node.set['statsd']['relay_server'] = true
|
||||
include_recipe 'statsd::server'
|
||||
end
|
||||
|
||||
# find graphing server address
|
||||
if Chef::Config[:solo] and not node['recipes'].include?("chef-solo-search")
|
||||
Chef::Log.warn("This recipe uses search. Chef Solo does not support search.")
|
||||
graphite_servers = []
|
||||
else
|
||||
graphite_servers = search(:node, "roles:#{node['swift']['statistics']['graphing_role']} AND chef_environment:#{node.chef_environment}")
|
||||
end
|
||||
graphite_host = "127.0.0.1"
|
||||
unless graphite_servers.empty?
|
||||
graphite_host = graphite_servers[0]['network']["ipaddress_#{node['swift']['statistics']['graphing_interface']}"]
|
||||
end
|
||||
|
||||
if node['swift']['statistics']['graphing_ip'].nil?
|
||||
node.set['statsd']['graphite_host'] = graphite_host
|
||||
else
|
||||
node.set['statsd']['graphite_host'] = node['swift']['statistics']['graphing_ip']
|
||||
end
|
||||
|
||||
#--------------
|
||||
# swift common
|
||||
#--------------
|
||||
|
||||
platform_options = node["swift"]["platform"]
|
||||
|
||||
# update repository if requested with the ubuntu cloud
|
||||
|
@ -91,3 +91,31 @@ template "/etc/swift/container-server.conf" do
|
||||
notifies :restart, "service[swift-container-updater]", :immediately
|
||||
notifies :restart, "service[swift-container-auditor]", :immediately
|
||||
end
|
||||
|
||||
# Ubuntu 12.04 packages are missing the swift-container-sync service scripts
|
||||
# See https://bugs.launchpad.net/cloud-archive/+bug/1250171
|
||||
if platform?("ubuntu")
|
||||
cookbook_file "/etc/init/swift-container-sync.conf" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
source "swift-container-sync.conf.upstart"
|
||||
action :create
|
||||
not_if "[ -e /etc/init/swift-container-sync.conf ]"
|
||||
end
|
||||
link "/etc/init.d/swift-container-sync" do
|
||||
to "/lib/init/upstart-job"
|
||||
not_if "[ -e /etc/init.d/swift-container-sync ]"
|
||||
end
|
||||
end
|
||||
|
||||
service_name=platform_options["service_prefix"] + 'swift-container-sync' + platform_options["service_suffix"]
|
||||
unless node["swift"]["container-server"]["allowed_sync_hosts"] == []
|
||||
service "swift-container-sync" do
|
||||
service_name service_name
|
||||
provider platform_options["service_provider"]
|
||||
supports :status => false, :restart => true
|
||||
action [:enable, :start]
|
||||
only_if "[ -e /etc/swift/container-server.conf ] && [ -e /etc/swift/container.ring.gz ]"
|
||||
end
|
||||
end
|
||||
|
@ -26,10 +26,29 @@ include_recipe "openstack-object-storage::ring-repo"
|
||||
platform_options = node["swift"]["platform"]
|
||||
|
||||
if node["swift"]["authmode"] == "swauth"
|
||||
platform_options["swauth_packages"].each.each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"] # retain configs
|
||||
case node["swift"]["swauth_source"]
|
||||
when "package"
|
||||
platform_options["swauth_packages"].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
end
|
||||
end
|
||||
when "git"
|
||||
git "#{Chef::Config[:file_cache_path]}/swauth" do
|
||||
repository node["swift"]["swauth_repository"]
|
||||
revision node["swift"]["swauth_version"]
|
||||
action :sync
|
||||
end
|
||||
|
||||
bash "install_swauth" do
|
||||
cwd "#{Chef::Config[:file_cache_path]}/swauth"
|
||||
user "root"
|
||||
group "root"
|
||||
code <<-EOH
|
||||
python setup.py install
|
||||
EOH
|
||||
environment 'PREFIX' => "/usr/local"
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -44,6 +63,19 @@ else
|
||||
auth_key = swift_secrets['dispersion_auth_key']
|
||||
end
|
||||
|
||||
if node['swift']['statistics']['enabled']
|
||||
template platform_options["swift_statsd_publish"] do
|
||||
source "swift-statsd-publish.py.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0755"
|
||||
end
|
||||
cron "cron_swift_statsd_publish" do
|
||||
command "#{platform_options['swift_statsd_publish']} > /dev/null 2>&1"
|
||||
minute "*/#{node["swift"]["statistics"]["report_frequency"]}"
|
||||
end
|
||||
end
|
||||
|
||||
template "/etc/swift/dispersion.conf" do
|
||||
source "dispersion.conf.erb"
|
||||
owner "swift"
|
||||
|
@ -26,7 +26,8 @@ end
|
||||
if node.run_list.expand(node.chef_environment).recipes.include?("openstack-object-storage::setup")
|
||||
Chef::Log.info("I ran the openstack-object-storage::setup so I will use my own swift passwords")
|
||||
else
|
||||
setup = search(:node, "chef_environment:#{node.chef_environment} AND roles:swift-setup")
|
||||
setup_role = node["swift"]["setup_chef_role"]
|
||||
setup = search(:node, "chef_environment:#{node.chef_environment} AND roles:#{setup_role}")
|
||||
if setup.length == 0
|
||||
Chef::Application.fatal! "You must have run the openstack-object-storage::setup recipe (on this or another node) before running the swift::proxy recipe on this node"
|
||||
elsif setup.length == 1
|
||||
@ -47,11 +48,35 @@ platform_options["proxy_packages"].each do |pkg|
|
||||
end
|
||||
end
|
||||
|
||||
package "python-swauth" do
|
||||
action :install
|
||||
only_if { node["swift"]["authmode"] == "swauth" }
|
||||
if node["swift"]["authmode"] == "swauth"
|
||||
case node["swift"]["swauth_source"]
|
||||
when "package"
|
||||
platform_options["swauth_packages"].each do |pkg|
|
||||
package pkg do
|
||||
action :install
|
||||
options platform_options["override_options"]
|
||||
end
|
||||
end
|
||||
when "git"
|
||||
git "#{Chef::Config[:file_cache_path]}/swauth" do
|
||||
repository node["swift"]["swauth_repository"]
|
||||
revision node["swift"]["swauth_version"]
|
||||
action :sync
|
||||
end
|
||||
|
||||
bash "install_swauth" do
|
||||
cwd "#{Chef::Config[:file_cache_path]}/swauth"
|
||||
user "root"
|
||||
group "root"
|
||||
code <<-EOH
|
||||
python setup.py install
|
||||
EOH
|
||||
environment 'PREFIX' => "/usr/local"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
package "python-swift-informant" do
|
||||
action :install
|
||||
only_if { node["swift"]["use_informant"] }
|
||||
@ -84,7 +109,8 @@ if Chef::Config[:solo]
|
||||
memcache_servers = [ "127.0.0.1:11211" ]
|
||||
else
|
||||
memcache_servers = []
|
||||
proxy_nodes = search(:node, "chef_environment:#{node.chef_environment} AND roles:swift-proxy-server")
|
||||
proxy_role = node["swift"]["proxy_server_chef_role"]
|
||||
proxy_nodes = search(:node, "chef_environment:#{node.chef_environment} AND roles:#{proxy_role}")
|
||||
proxy_nodes.each do |proxy|
|
||||
proxy_ip = locate_ip_in_cidr(node["swift"]["network"]["proxy-cidr"], proxy)
|
||||
next if not proxy_ip # skip nil ips so we dont break the config
|
||||
|
@ -22,7 +22,8 @@ include_recipe "openstack-object-storage::common"
|
||||
if Chef::Config[:solo]
|
||||
Chef::Application.fatal! "This recipe uses search. Chef Solo does not support search."
|
||||
else
|
||||
setup_role_count = search(:node, "chef_environment:#{node.chef_environment} AND roles:swift-setup").length
|
||||
setup_role = node["swift"]["setup_chef_role"]
|
||||
setup_role_count = search(:node, "chef_environment:#{node.chef_environment} AND roles:#{setup_role}").length
|
||||
if setup_role_count > 1
|
||||
Chef::Application.fatal! "You can only have one node with the swift-setup role"
|
||||
end
|
||||
@ -42,9 +43,32 @@ platform_options["proxy_packages"].each do |pkg|
|
||||
end
|
||||
end
|
||||
|
||||
package "python-swauth" do
|
||||
action :upgrade
|
||||
only_if { node["swift"]["authmode"] == "swauth" }
|
||||
if node["swift"]["authmode"] == "swauth"
|
||||
case node["swift"]["swauth_source"]
|
||||
when "package"
|
||||
platform_options["swauth_packages"].each do |pkg|
|
||||
package pkg do
|
||||
action :upgrade
|
||||
options platform_options["override_options"]
|
||||
end
|
||||
end
|
||||
when "git"
|
||||
git "#{Chef::Config[:file_cache_path]}/swauth" do
|
||||
repository node["swift"]["swauth_repository"]
|
||||
revision node["swift"]["swauth_version"]
|
||||
action :sync
|
||||
end
|
||||
|
||||
bash "install_swauth" do
|
||||
cwd "#{Chef::Config[:file_cache_path]}/swauth"
|
||||
user "root"
|
||||
group "root"
|
||||
code <<-EOH
|
||||
python setup.py install
|
||||
EOH
|
||||
environment 'PREFIX' => "/usr/local"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
package "python-swift-informant" do
|
||||
|
@ -14,12 +14,12 @@ describe 'openstack-object-storage::common' do
|
||||
@node = @chef_run.node
|
||||
@node.set['platform_family'] = "debian"
|
||||
@node.set['lsb']['codename'] = "precise"
|
||||
@node.set['swift']['release'] = "folsom"
|
||||
@node.set['swift']['release'] = "grizzly"
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['git_builder_ip'] = '10.0.0.10'
|
||||
|
||||
# TODO: this does not work
|
||||
# ::Chef::Log.should_receive(:info).with("chefspec: precise-updates/folsom")
|
||||
# ::Chef::Log.should_receive(:info).with("chefspec: precise-updates/grizzly")
|
||||
|
||||
@chef_run.converge "openstack-object-storage::common"
|
||||
end
|
||||
|
@ -16,6 +16,8 @@ describe 'openstack-object-storage::container-server' do
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['network']['container-bind-ip'] = '10.0.0.1'
|
||||
@node.set['swift']['network']['container-bind-port'] = '8080'
|
||||
@node.set['swift']['container-server']['allowed_sync_hosts'] = ['host1', 'host2', 'host3']
|
||||
@node.set['swift']['container-bind-port'] = '8080'
|
||||
@node.set['swift']['disk_enum_expr'] = "[{ 'sda' => {}}]"
|
||||
@node.set['swift']['disk_test_filter'] = [ "candidate =~ /sd[^a]/ or candidate =~ /hd[^a]/ or candidate =~ /vd[^a]/ or candidate =~ /xvd[^a]/",
|
||||
"File.exist?('/dev/' + candidate)",
|
||||
@ -33,7 +35,7 @@ describe 'openstack-object-storage::container-server' do
|
||||
end
|
||||
|
||||
it "starts swift container services on boot" do
|
||||
%w{swift-container swift-container-auditor swift-container-replicator swift-container-updater}.each do |svc|
|
||||
%w{swift-container swift-container-auditor swift-container-replicator swift-container-updater swift-container-sync}.each do |svc|
|
||||
expect(@chef_run).to set_service_to_start_on_boot svc
|
||||
end
|
||||
end
|
||||
@ -52,12 +54,34 @@ describe 'openstack-object-storage::container-server' do
|
||||
expect(sprintf("%o", @file.mode)).to eq "600"
|
||||
end
|
||||
|
||||
it "template contents" do
|
||||
pending "TODO: implement"
|
||||
it "has allowed sync hosts" do
|
||||
expect(@chef_run).to create_file_with_content @file.name,
|
||||
"allowed_sync_hosts = host1,host2,host3"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
it "should create container sync upstart conf for ubuntu" do
|
||||
expect(@chef_run).to create_cookbook_file "/etc/init/swift-container-sync.conf"
|
||||
end
|
||||
|
||||
it "should create container sync init script for ubuntu" do
|
||||
expect(@chef_run).to create_link "/etc/init.d/swift-container-sync"
|
||||
end
|
||||
|
||||
describe "/etc/swift/container-server.conf" do
|
||||
|
||||
before do
|
||||
@node = @chef_run.node
|
||||
@node.set["swift"]["container-server"]["allowed_sync_hosts"] = []
|
||||
@chef_run.converge "openstack-object-storage::container-server"
|
||||
@file = @chef_run.template "/etc/swift/container-server.conf"
|
||||
end
|
||||
|
||||
it "has no allowed_sync_hosts on empty lists" do
|
||||
expect(@chef_run).not_to create_file_with_content @file.name,
|
||||
/^allowed_sync_hots =/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ describe 'openstack-object-storage::disks' do
|
||||
@node = @chef_run.node
|
||||
@node.set['platform_family'] = "debian"
|
||||
@node.set['lsb']['codename'] = "precise"
|
||||
@node.set['swift']['release'] = "folsom"
|
||||
@node.set['swift']['release'] = "grizzly"
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['git_builder_ip'] = '10.0.0.10'
|
||||
@node.set['swift']['disk_enum_expr'] = "[{ 'sda' => {}}]"
|
||||
|
@ -14,6 +14,9 @@ describe 'openstack-object-storage::management-server' do
|
||||
@node = @chef_run.node
|
||||
@node.set['lsb']['code'] = 'precise'
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['statistics']['enabled'] = true
|
||||
@node.set['swift']['swauth_source'] = 'package'
|
||||
@node.set['swift']['platform']['swauth_packages'] = ['swauth']
|
||||
|
||||
@chef_run.converge "openstack-object-storage::management-server"
|
||||
end
|
||||
@ -42,6 +45,27 @@ describe 'openstack-object-storage::management-server' do
|
||||
|
||||
end
|
||||
|
||||
describe "/usr/local/bin/swift-statsd-publish.py" do
|
||||
|
||||
before do
|
||||
@file = @chef_run.template "/usr/local/bin/swift-statsd-publish.py"
|
||||
end
|
||||
|
||||
it "has proper owner" do
|
||||
expect(@file).to be_owned_by "root", "root"
|
||||
end
|
||||
|
||||
it "has proper modes" do
|
||||
expect(sprintf("%o", @file.mode)).to eq "755"
|
||||
end
|
||||
|
||||
it "has expected statsd host" do
|
||||
expect(@chef_run).to create_file_with_content @file.name,
|
||||
"self.statsd_host = '127.0.0.1'"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -14,6 +14,8 @@ describe 'openstack-object-storage::proxy-server' do
|
||||
@node = @chef_run.node
|
||||
@node.set['lsb']['code'] = 'precise'
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['platform']['swauth_packages'] = ['swauth']
|
||||
@node.set['swift']['swauth_source'] = 'package'
|
||||
@node.set['swift']['network']['proxy-bind-ip'] = '10.0.0.1'
|
||||
@node.set['swift']['network']['proxy-bind-port'] = '8080'
|
||||
@chef_run.converge "openstack-object-storage::proxy-server"
|
||||
@ -28,7 +30,7 @@ describe 'openstack-object-storage::proxy-server' do
|
||||
end
|
||||
|
||||
it "installs swauth package if swauth is selected" do
|
||||
expect(@chef_run).to install_package "python-swauth"
|
||||
expect(@chef_run).to install_package "swauth"
|
||||
end
|
||||
|
||||
it "starts swift-proxy on boot" do
|
||||
|
@ -14,7 +14,7 @@ describe 'openstack-object-storage::ring-repo' do
|
||||
@node = @chef_run.node
|
||||
@node.set['platform_family'] = "debian"
|
||||
@node.set['lsb']['codename'] = "precise"
|
||||
@node.set['swift']['release'] = "folsom"
|
||||
@node.set['swift']['release'] = "grizzly"
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['git_builder_ip'] = '10.0.0.10'
|
||||
@chef_run.converge "openstack-object-storage::ring-repo"
|
||||
|
@ -14,7 +14,7 @@ describe 'openstack-object-storage::rsync' do
|
||||
@node = @chef_run.node
|
||||
@node.set['platform_family'] = "debian"
|
||||
@node.set['lsb']['codename'] = "precise"
|
||||
@node.set['swift']['release'] = "folsom"
|
||||
@node.set['swift']['release'] = "grizzly"
|
||||
@node.set['swift']['authmode'] = 'swauth'
|
||||
@node.set['swift']['git_builder_ip'] = '10.0.0.10'
|
||||
@chef_run.converge "openstack-object-storage::rsync"
|
||||
|
@ -15,11 +15,11 @@
|
||||
bind_ip = <%= @bind_ip %>
|
||||
bind_port = <%= @bind_port %>
|
||||
workers = 10
|
||||
<% if node[:swift][:enable_statistics] -%>
|
||||
<% if node[:swift][:statistics][:enabled] -%>
|
||||
log_statsd_host = localhost
|
||||
log_statsd_port = 8125
|
||||
log_statsd_default_sample_rate = 1
|
||||
log_statsd_metric_prefix = openstack.swift.<%= node[:hostname] %>
|
||||
log_statsd_default_sample_rate = <%= node[:swift][:statistics][:sample_rate] %>
|
||||
log_statsd_metric_prefix = <%= node[:swift][:statistics][:statsd_prefix] %>.<%= node[:hostname] %>
|
||||
<% end %>
|
||||
|
||||
[pipeline:main]
|
||||
|
@ -18,12 +18,16 @@
|
||||
bind_ip = <%= @bind_ip %>
|
||||
bind_port = <%= @bind_port %>
|
||||
workers = 10
|
||||
<% if node[:swift][:enable_statistics] -%>
|
||||
<% if node["swift"]["enable_statistics"] -%>
|
||||
log_statsd_host = localhost
|
||||
log_statsd_port = 8125
|
||||
log_statsd_default_sample_rate = 1
|
||||
log_statsd_metric_prefix = openstack.swift.<%= node[:hostname] %>
|
||||
<% end %>
|
||||
log_statsd_metric_prefix = openstack.swift.<%= node["hostname"] %>
|
||||
<% end -%>
|
||||
|
||||
<% if node["swift"]["container-server"]["allowed_sync_hosts"] -%>
|
||||
allowed_sync_hosts = <%= node["swift"]["container-server"]["allowed_sync_hosts"].join(",") %>
|
||||
<% end -%>
|
||||
|
||||
[pipeline:main]
|
||||
pipeline = container-server
|
||||
@ -77,12 +81,14 @@ use = egg:swift#container
|
||||
|
||||
[container-sync]
|
||||
# You can override the default log routing for this app here (don't use set!):
|
||||
# log_name = container-sync
|
||||
# log_facility = LOG_LOCAL0
|
||||
# log_level = INFO
|
||||
log_name = <%= node["swift"]["container-server"]["container-sync"]["log_name"] %>
|
||||
log_facility = <%= node["swift"]["container-server"]["container-sync"]["log_facility"] %>
|
||||
log_level = <%= node["swift"]["container-server"]["container-sync"]["log_level"] %>
|
||||
# If you need to use an HTTP Proxy, set it here; defaults to no proxy.
|
||||
# sync_proxy = http://127.0.0.1:8888
|
||||
<% if node["swift"]["container-server"]["container-sync"]["sync_proxy"] -%>
|
||||
sync_proxy = <%= node["swift"]["container-server"]["container-sync"]["sync_proxy"] %>
|
||||
<% end -%>
|
||||
# Will sync, at most, each container once per interval
|
||||
# interval = 300
|
||||
interval = <%= node["swift"]["container-server"]["container-sync"]["interval"] %>
|
||||
# Maximum amount of time to spend syncing each container per pass
|
||||
# container_time = 60
|
||||
container_time = <%= node["swift"]["container-server"]["container-sync"]["container_time"] %>
|
||||
|
@ -16,11 +16,11 @@
|
||||
bind_ip = <%= @bind_ip %>
|
||||
bind_port = <%= @bind_port %>
|
||||
workers = 10
|
||||
<% if node[:swift][:enable_statistics] -%>
|
||||
<% if node[:swift][:statistics][:enabled] -%>
|
||||
log_statsd_host = localhost
|
||||
log_statsd_port = 8125
|
||||
log_statsd_default_sample_rate = 1
|
||||
log_statsd_metric_prefix = openstack.swift.<%= node[:hostname] %>
|
||||
log_statsd_default_sample_rate = <%= node[:swift][:statistics][:sample_rate] %>
|
||||
log_statsd_metric_prefix = <%= node[:swift][:statistics][:statsd_prefix] %>.<%= node[:hostname] %>
|
||||
<% end %>
|
||||
|
||||
[pipeline:main]
|
||||
|
@ -8,15 +8,23 @@ when "swauth"
|
||||
end
|
||||
|
||||
account_management=false
|
||||
if node[:roles].include?("swift-management-server") and node[:swift][:authmode] == "swauth" then
|
||||
if node[:swift][:authmode] == "swauth" then
|
||||
account_management="true"
|
||||
end
|
||||
|
||||
# need to both: 1) add tempurl before auth middleware, 2) set allow_overrides=true
|
||||
tempurl_toggle=false
|
||||
if node[:swift][:authmode] == "swauth" and node[:swift][:tempurl][:enabled] == true then
|
||||
tempurl_toggle = true
|
||||
pipeline = "tempurl swauth"
|
||||
end
|
||||
|
||||
-%>
|
||||
# This file is managed by chef. Do not edit it.
|
||||
#
|
||||
# Cluster info:
|
||||
# Auth mode: <%= node[:swift][:authmode] %>
|
||||
# Management server: <%= node[:roles].include?("swift-management-server") %>
|
||||
# Management server: <%= node[:roles].include?(node[:swift][:management_server_chef_role]) %>
|
||||
# Account management enabled: <%= account_management %>
|
||||
# Auth pipeline: <%= pipeline %>
|
||||
|
||||
@ -38,11 +46,11 @@ end
|
||||
workers = <%= [ node[:cpu][:total] - 1, 1 ].max %>
|
||||
bind_ip = <%= @bind_host %>
|
||||
bind_port = <%= @bind_port %>
|
||||
<% if node[:swift][:enable_statistics] -%>
|
||||
<% if node[:swift][:statistics][:enabled] -%>
|
||||
log_statsd_host = localhost
|
||||
log_statsd_port = 8125
|
||||
log_statsd_default_sample_rate = 1
|
||||
log_statsd_metric_prefix = openstack.swift.<%= node[:hostname] %>
|
||||
log_statsd_default_sample_rate = <%= node[:swift][:statistics][:sample_rate] %>
|
||||
log_statsd_metric_prefix = <%= node[:swift][:statistics][:statsd_prefix] %>.<%= node[:hostname] %>
|
||||
<% end %>
|
||||
|
||||
|
||||
@ -82,13 +90,7 @@ use = egg:swift#proxy
|
||||
# If set to 'true' authorized accounts that do not yet exist within the Swift
|
||||
# cluster will be automatically created.
|
||||
# account_autocreate = false
|
||||
######
|
||||
#
|
||||
# N.B. ideally allow_account_management would only be set on the
|
||||
# management server, but swauth will delete using the cluster url
|
||||
# and not the local url
|
||||
# allow_account_managemnet = <%= account_management %>
|
||||
allow_account_management = true
|
||||
allow_account_management = <%= account_management %>
|
||||
|
||||
<% if @authmode == "keystone" -%>
|
||||
account_autocreate = true
|
||||
@ -106,6 +108,12 @@ default_swift_cluster = local#<%= node[:swift][:swift_url] %>#<%= node[:swift][:
|
||||
<% else %>
|
||||
default_swift_cluster = local#<%= node[:swift][:swift_url] %>
|
||||
<% end %>
|
||||
<% if tempurl_toggle -%>
|
||||
allow_overrides = true
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if node["swift"]["container-server"]["allowed_sync_hosts"] -%>
|
||||
allowed_sync_hosts = <%= node["swift"]["container-server"]["allowed_sync_hosts"].join(",") %>
|
||||
<% end %>
|
||||
|
||||
[filter:healthcheck]
|
||||
@ -253,7 +261,7 @@ use = egg:swift#proxy_logging
|
||||
# You can use log_statsd_* from [DEFAULT] or override them here:
|
||||
# access_log_statsd_host = localhost
|
||||
# access_log_statsd_port = 8125
|
||||
# access_log_statsd_default_sample_rate = 1
|
||||
# access_log_statsd_default_sample_rate = <%= node[:swift][:statistics][:sample_rate] %>
|
||||
# access_log_statsd_metric_prefix =
|
||||
# access_log_headers = False
|
||||
# What HTTP methods are allowed for StatsD logging (comma-sep); request methods
|
||||
|
@ -0,0 +1,157 @@
|
||||
#!/usr/bin/env python
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
# coding=utf-8
|
||||
#
|
||||
# Author: Alan Meadows <alan.meadows@gmail.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
"""
|
||||
THIS FILE WAS INSTALLED BY CHEF. ANY CHANGES WILL BE OVERWRITTEN.
|
||||
|
||||
Openstack swift collector for recon and dispersion reports. Will send
|
||||
back dispersion reporting metrics as well as swift recon statistics
|
||||
to a statsd server for graphite consumption
|
||||
"""
|
||||
|
||||
from subprocess import Popen, PIPE, check_call
|
||||
from socket import socket, AF_INET, SOCK_DGRAM
|
||||
import re
|
||||
import os
|
||||
|
||||
try:
|
||||
import json
|
||||
json # workaround for pyflakes issue #13
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
|
||||
class OpenStackSwiftStatisticsCollector(object):
|
||||
|
||||
def __init__(self):
|
||||
'''Setup some initial values defined by chef'''
|
||||
|
||||
self.statsd_host = '<%= node[:swift][:statistics][:statsd_host] %>'
|
||||
self.statsd_port = <%= node[:swift][:statistics][:statsd_port] %>
|
||||
self.statsd_prefix = '<%= node[:swift][:statistics][:statsd_prefix] %>'
|
||||
<% if node[:swift][:statistics][:enable_dispersion_report] -%>
|
||||
self.enable_dispersion_report = True
|
||||
<% else %>
|
||||
self.enable_dispersion_report = False
|
||||
<% end %>
|
||||
<% if node[:swift][:statistics][:enable_recon_report] -%>
|
||||
self.enable_recon_report = True
|
||||
<% else %>
|
||||
self.enable_recon_report = False
|
||||
<% end %>
|
||||
<% if node[:swift][:statistics][:enable_disk_report] -%>
|
||||
self.enable_disk_report = True
|
||||
<% else %>
|
||||
self.enable_disk_report = False
|
||||
<% end %>
|
||||
self.recon_account_cache = '<%= node[:swift][:statistics][:recon_account_cache] %>'
|
||||
self.recon_container_cache = '<%= node[:swift][:statistics][:recon_container_cache] %>'
|
||||
self.recon_object_cache = '<%= node[:swift][:statistics][:recon_object_cache] %>'
|
||||
|
||||
def _dispersion_report(self):
|
||||
"""
|
||||
Swift Dispersion Report Collection
|
||||
"""
|
||||
p = Popen(['/usr/bin/swift-dispersion-report', '-j'],
|
||||
stdout=PIPE, stderr=PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
self.publish('%s.dispersion.errors' % self.statsd_prefix, len(stderr.split('\n')) - 1)
|
||||
data = json.loads(stdout)
|
||||
for t in ('object', 'container'):
|
||||
for (k, v) in data[t].items():
|
||||
self.publish('%s.dispersion.%s.%s' % (self.statsd_prefix, t, k), v)
|
||||
|
||||
def _recon_report(self):
|
||||
"""
|
||||
Swift Recon Collection
|
||||
"""
|
||||
recon_cache = {'account': self.recon_account_cache,
|
||||
'container': self.recon_container_cache,
|
||||
'object': self.recon_object_cache}
|
||||
for recon_type in recon_cache:
|
||||
if not os.access(recon_cache[recon_type], os.R_OK):
|
||||
continue
|
||||
try:
|
||||
f = open(recon_cache[recon_type])
|
||||
try:
|
||||
rmetrics = json.loads(f.readlines()[0].strip())
|
||||
metrics = self._process_cache(rmetrics)
|
||||
for k, v in metrics:
|
||||
metric_name = '%s.%s.%s' % (self.statsd_prefix, recon_type, ".".join(k))
|
||||
if isinstance(v, (int, float)):
|
||||
self.publish(metric_name, v)
|
||||
except (ValueError, IndexError):
|
||||
continue
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def _disk_report(self):
|
||||
"""
|
||||
Swift Disk Capacity Report
|
||||
"""
|
||||
p = Popen(['/usr/bin/swift-recon', '-d'],
|
||||
stdout=PIPE, stderr=PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
|
||||
used, total = 0, 0
|
||||
match = re.search(r'.* space used: ([0-9]*\.?[0-9]+) of ([0-9]*\.?[0-9]+)', stdout, re.M|re.I)
|
||||
if match:
|
||||
used, total = [int(i) for i in match.groups()]
|
||||
|
||||
highest, avg = 0, 0
|
||||
match = re.search(r'.* lowest:.+highest: ([0-9]*\.?[0-9]+)%, avg: ([0-9]*\.?[0-9]+)%', stdout, re.M|re.I)
|
||||
if match:
|
||||
highest, avg = match.groups()
|
||||
|
||||
self.publish('%s.capacity.bytes_used' % self.statsd_prefix, used)
|
||||
self.publish('%s.capacity.bytes_free' % self.statsd_prefix, total-used)
|
||||
self.publish('%s.capacity.bytes_utilization' % self.statsd_prefix, int((used/total)*100))
|
||||
self.publish('%s.capacity.single_disk_utilization_highest' % self.statsd_prefix, highest)
|
||||
self.publish('%s.capacity.single_disk_utilization_average' % self.statsd_prefix, avg)
|
||||
|
||||
def collect(self):
|
||||
|
||||
if (self.enable_dispersion_report):
|
||||
self._dispersion_report()
|
||||
|
||||
if (self.enable_recon_report):
|
||||
self._recon_report()
|
||||
|
||||
if (self.enable_disk_report):
|
||||
self._disk_report()
|
||||
|
||||
def publish(self, metric_name, value):
|
||||
"""Publish a metric to statsd server"""
|
||||
# TODO: IPv6 support
|
||||
print '%s:%s|g' % (metric_name.encode('utf-8'), value), (self.statsd_host, self.statsd_port)
|
||||
udp_sock = socket(AF_INET, SOCK_DGRAM)
|
||||
udp_sock.sendto('%s:%s|g' % (metric_name.encode('utf-8'), value), (self.statsd_host, self.statsd_port))
|
||||
|
||||
def _process_cache(self, d, path=()):
|
||||
"""Recusively walk a nested recon cache dict to obtain path/values"""
|
||||
metrics = []
|
||||
for k, v in d.iteritems():
|
||||
if not isinstance(v, dict):
|
||||
metrics.append((path + (k,), v))
|
||||
else:
|
||||
self._process_cache(v, path + (k,))
|
||||
return metrics
|
||||
|
||||
if __name__ == '__main__':
|
||||
collector = OpenStackSwiftStatisticsCollector()
|
||||
collector.collect()
|
@ -0,0 +1,6 @@
|
||||
name "os-object-storage-proxy"
|
||||
description "OpenStack object storage server responsible for generating initial settings"
|
||||
run_list(
|
||||
"role[os-base]",
|
||||
"recipe[openstack-object-storage::setup]"
|
||||
)
|
@ -2,9 +2,10 @@ name "os-object-storage"
|
||||
description "OpenStack object storage roll-up role"
|
||||
run_list(
|
||||
"role[os-base]",
|
||||
"role[os-object-storage-account]",
|
||||
"role[os-object-storage-container]",
|
||||
"role[os-object-storage-setup]",
|
||||
"role[os-object-storage-management]",
|
||||
"role[os-object-storage-proxy]",
|
||||
"role[os-object-storage-object]",
|
||||
"role[os-object-storage-proxy]"
|
||||
"role[os-object-storage-container]",
|
||||
"role[os-object-storage-account]"
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user