make ubuntu openstack works with proxy

Partial-Bug: 1392131
Change-Id: I5485d4543705cb3affce1937d1d7a6f1fd97b866
This commit is contained in:
xiaodongwang 2014-11-12 17:11:45 -08:00
parent 283b747cf5
commit 06c19826da
18 changed files with 196 additions and 195 deletions

View File

@ -96,47 +96,49 @@ def build_repo(uri, distribution, components, trusted, arch, add_deb_src)
end
action :add do
# add key
if new_resource.keyserver && new_resource.key
install_key_from_keyserver(new_resource.key, new_resource.keyserver)
elsif new_resource.key
install_key_from_uri(new_resource.key)
end
if node['local_repo'].nil? or node['local_repo'].empty?
# add key
if new_resource.keyserver && new_resource.key
install_key_from_keyserver(new_resource.key, new_resource.keyserver)
elsif new_resource.key
install_key_from_uri(new_resource.key)
end
file '/var/lib/apt/periodic/update-success-stamp' do
action :nothing
end
file '/var/lib/apt/periodic/update-success-stamp' do
action :nothing
end
execute 'apt-cache gencaches' do
ignore_failure true
action :nothing
end
execute 'apt-cache gencaches' do
ignore_failure true
action :nothing
end
execute 'apt-get update' do
command "apt-get update -o Dir::Etc::sourcelist='sources.list.d/#{new_resource.name}.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'"
ignore_failure true
action :nothing
notifies :run, 'execute[apt-cache gencaches]', :immediately
end
execute 'apt-get update' do
command "apt-get update -o Dir::Etc::sourcelist='sources.list.d/#{new_resource.name}.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'"
ignore_failure true
action :nothing
notifies :run, 'execute[apt-cache gencaches]', :immediately
end
# build repo file
repository = build_repo(
new_resource.uri,
new_resource.distribution,
new_resource.components,
new_resource.trusted,
new_resource.arch,
new_resource.deb_src
)
# build repo file
repository = build_repo(
new_resource.uri,
new_resource.distribution,
new_resource.components,
new_resource.trusted,
new_resource.arch,
new_resource.deb_src
)
file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
owner 'root'
group 'root'
mode 00644
content repository
action :create
notifies :delete, 'file[/var/lib/apt/periodic/update-success-stamp]', :immediately
notifies :run, 'execute[apt-get update]', :immediately if new_resource.cache_rebuild
file "/etc/apt/sources.list.d/#{new_resource.name}.list" do
owner 'root'
group 'root'
mode 00644
content repository
action :create
notifies :delete, 'file[/var/lib/apt/periodic/update-success-stamp]', :immediately
notifies :run, 'execute[apt-get update]', :immediately if new_resource.cache_rebuild
end
end
end

View File

@ -44,20 +44,14 @@ node['mysql']['client']['packages'].each do |name|
resources("package[#{name}]").run_action(:install)
end
# unknown reason cause chef-client not to honor .gemrc immediately
# even not until timeout is reached, so specify the options explicitly.
if node['local_repo'].nil? or node['local_repo'].empty?
if node['proxy_url']
gem_package 'mysql' do
options("--http-proxy #{node['proxy_url']}")
action :install
end
else
chef_gem 'mysql'
end
else
case node['platform_family']
when 'debian'
gem_package 'mysql' do
options("--clear-sources --source #{node['local_repo']}/gem_repo/")
action :install
version '2.9.1'
end
when 'rhel'
chef_gem 'mysql' do
action :install
version '2.9.1'
end

View File

@ -42,10 +42,21 @@ if node['openstack']['block-storage']['volume']['driver'] == 'cinder.volume.driv
node.override['ceph']['rhel']['extras']['repository'] = "#{node['local_repo']}/compass_repo"
end
save_http_proxy = Chef::Config[:http_proxy]
unless node['proxy_url'].nil? or node['proxy_url'].empty?
Chef::Config[:http_proxy] = "#{node['proxy_url']}"
ENV['http_proxy'] = "#{node['proxy_url']}"
ENV['HTTP_PROXY'] = "#{node['proxy_url']}"
end
execute "rpm -Uvh --force #{node['ceph']['rhel']['extras']['repository']}/qemu-kvm-0.12.1.2-2.415.el6.3ceph.x86_64.rpm #{node['ceph']['rhel']['extras']['repository']}/qemu-img-0.12.1.2-2.415.el6.3ceph.x86_64.rpm" do
not_if "rpm -qa | grep qemu | grep ceph"
end
Chef::Config[:http_proxy] = save_http_proxy
ENV['http_proxy'] = save_http_proxy
ENV['HTTP_PROXY'] = save_http_proxy
secret_uuid = node['openstack']['block-storage']['rbd_secret_uuid']
rbd_user = node['openstack']['compute']['libvirt']['rbd']['rbd_user']

View File

@ -48,6 +48,17 @@ service_pass = get_password 'service', 'openstack-image'
service_tenant_name = node['openstack']['image']['service_tenant_name']
service_user = node['openstack']['image']['service_user']
unless node['proxy_url'].nil? or node['proxy_url'].empty?
node['openstack']['image']['upload_images'].each do |img|
execute "download_#{node['openstack']['image']['upload_image'][img.to_sym]}" do
command "wget #{node['openstack']['image']['upload_image'][img.to_sym]}"
cwd Chef::Config['file_cache_path']
not_if { ::File.exists?(::File.basename(node['openstack']['image']['upload_image'][img.to_sym])) }
environment ({ 'http_proxy' => node['proxy_url'], 'https_proxy' => node['proxy_url'] })
end
end
end
node['openstack']['image']['upload_images'].each do |img|
openstack_image_image "Image setup for #{img.to_s}" do
image_url node['openstack']['image']['upload_image'][img.to_sym]

View File

@ -84,34 +84,10 @@ if node['lsb'] && node['lsb']['codename'] == 'precise' && node['openstack']['net
end
end
dhcp_options = node['openstack']['network']['dhcp']
src_filename = dhcp_options['dnsmasq_filename']
src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filename}"
extract_path = "#{Chef::Config['file_cache_path']}/#{dhcp_options['dnsmasq_checksum']}"
remote_file src_filepath do
source dhcp_options['dnsmasq_url']
checksum dhcp_options['dnsmasq_checksum']
owner 'root'
group 'root'
mode 00644
end
bash 'extract_package' do
cwd ::File.dirname(src_filepath)
code <<-EOH
mkdir -p #{extract_path}
tar xzf #{src_filename} -C #{extract_path}
mv #{extract_path}/*/* #{extract_path}/
cd #{extract_path}/
echo '2.65' > VERSION
debian/rules binary
EOH
not_if { ::File.exists?(extract_path) }
notifies :install, 'dpkg_package[dnsmasq-utils]', :immediately
notifies :install, 'dpkg_package[dnsmasq-base]', :immediately
notifies :install, 'dpkg_package[dnsmasq]', :immediately
package 'dnsmasq-utils'
package 'dnsmasq-base'
package 'dnsmasq' do
notifies :create, 'ruby_block[wait for dnsmasq]', :immediately
end
# wait for dnsmasq to start properly. Don't wait forever
@ -129,19 +105,4 @@ if node['lsb'] && node['lsb']['codename'] == 'precise' && node['openstack']['net
end
action :nothing
end
dpkg_package 'dnsmasq-utils' do
source "#{extract_path}/../dnsmasq-utils_#{dhcp_options['dnsmasq_dpkgversion']}_#{dhcp_options['dnsmasq_architecture']}.deb"
action :nothing
end
dpkg_package 'dnsmasq-base' do
source "#{extract_path}/../dnsmasq-base_#{dhcp_options['dnsmasq_dpkgversion']}_#{dhcp_options['dnsmasq_architecture']}.deb"
action :nothing
end
dpkg_package 'dnsmasq' do
source "#{extract_path}/../dnsmasq_#{dhcp_options['dnsmasq_dpkgversion']}_all.deb"
action :nothing
notifies :create, 'ruby_block[wait for dnsmasq]', :immediately
end
end

View File

@ -1,3 +1,4 @@
#if $getVar("local_repo","") == ""
cat << EOF > /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
@ -12,36 +13,37 @@ cat << EOF > /etc/yum.repos.d/CentOS-Base.repo
#
[base]
name=CentOS-\\$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=os
baseurl=http://mirror.centos.org/centos/\\$releasever/os/\\$basearch/
name=CentOS-6.5 - Base
mirrorlist=http://mirrorlist.centos.org/?release=6.5=\\$basearch&repo=os
baseurl=http://mirror.centos.org/centos/6.5/os/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#released updates
# released updates
[updates]
name=CentOS-\\$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=updates
baseurl=http://mirror.centos.org/centos/\\$releasever/updates/\\$basearch/
name=CentOS-6.5 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=\\$basearch&repo=updates
baseurl=http://mirror.centos.org/centos/6.5/updates/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#additional packages that may be useful
# additional packages that may be useful
[extras]
name=CentOS-\\$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=extras
baseurl=http://mirror.centos.org/centos/\\$releasever/extras/\\$basearch/
name=CentOS-6.5 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=\\$basearch&repo=extras
baseurl=http://mirror.centos.org/centos/6.5/extras/\\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
skip_if_unavailable=1
#end if
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-\\$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=centosplus
baseurl=http://mirror.centos.org/centos/\\$releasever/centosplus/\\$basearch/
name=CentOS-6.5 - Plus
mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=\\$basearch&repo=centosplus
baseurl=http://mirror.centos.org/centos/6.5/centosplus/\\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
@ -49,9 +51,9 @@ skip_if_unavailable=1
#contrib - packages by Centos Users
[contrib]
name=CentOS-\\$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=\\$releasever&arch=\\$basearch&repo=contrib
baseurl=http://mirror.centos.org/centos/\\$releasever/contrib/\\$basearch/
name=CentOS-6.5 - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=\\$basearch&repo=contrib
baseurl=http://mirror.centos.org/centos/6.5/contrib/\\$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

View File

@ -1,3 +1,4 @@
#if $getVar("local_repo","") == ""
cat << EOF > /etc/yum.repos.d/CentOS-Debuginfo.repo
# CentOS-Debug.repo
#
@ -21,3 +22,4 @@ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6
enabled=0
skip_if_unavailable=1
EOF
#end if

View File

@ -1,3 +1,4 @@
#if $getVar("local_repo","") != ""
cat << EOF > /etc/yum.repos.d/CentOS-Vault.repo
# CentOS-Vault.repo
#
@ -211,3 +212,4 @@ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=0
skip_if_unavailable=1
EOF
#end if

View File

@ -10,20 +10,26 @@
#end if
#end for
#set $proxy_url = ""
#if $getVar("local_repo","") != ""
#set $local_repo_url = $local_repo
#else
#set $local_repo_url = ""
#if $getVar("proxy","") != ""
#set $proxy_url = $proxy
#end if
#end if
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
instances=\\$(pgrep chef_client_run.sh | wc -l)
if [ \\$instances -gt 1 ]; then
echo "there are chef-client run instances '\\$instances' running" &>> /tmp/chef.log
exit 1
fi
touch /tmp/chef.log
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
clients=\\$(pgrep chef-client)
if [ "\\$?" == "0" ]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
sleep 1m
break
else
echo "knife search nodes" &>> /tmp/chef.log
USER=root HOME=/root knife search node "name:\\$HOSTNAME.*" -i -a name &>> /tmp/chef.log
@ -34,16 +40,11 @@ while true; do
mkdir -p /var/log/chef/\\$node
if [ ! -f /etc/chef/\\$node.json ]; then
cat << EOL > /etc/chef/\\$node.json
#if $getVar("local_repo","") != ""
{
"local_repo": "$local_repo",
"local_repo": "$local_repo_url",
"proxy_url": "$proxy_url",
"ip_address": "$ip_address"
}
#else
{
"ip_address": "$ip_address"
}
#end if
EOL
fi
if [ ! -f "/etc/chef/\\$node.pem" ]; then
@ -67,9 +68,9 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
else
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log

View File

@ -4,20 +4,6 @@ log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
#end if
#if $getVar('proxy', '') != ""
http_proxy '$proxy'
https_proxy '$proxy'
ENV['http_proxy'] = '$proxy'
ENV['https_proxy'] = '$proxy'
ENV['HTTP_PROXY'] = '$proxy'
ENV['HTTPS_PROXY'] = '$proxy'
#if $getVar('ignore_proxy', '') != ""
#set ignore_proxy = ','.join([proxy.strip() for proxy in $ignore_proxy.split(',') if proxy.strip()])
no_proxy '$ignore_proxy'
ENV['no_proxy'] = '$ignore_proxy'
ENV['NO_PROXY'] = '$ignore_proxy'
#end if
#end if
validation_client_name 'chef-validator'
json_attribs nil
pid_file '/var/run/chef-client.pid'

View File

@ -1,14 +1,20 @@
cat << EOF > /root/.gemrc
#if $getVar("local_repo","") == "" and $getVar('proxy', '') != ""
gem: --no-ri --no-rdoc --http-proxy=$proxy
#else
gem: --no-ri --no-rdoc
#end if
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
## - http://gems.rubyforge.org/
#if $getVar("local_repo","") != ""
- $local_repo/gem_repo/
#else
- https://rubygems.org/
#end if
:update_sources: true
:verbose: true
EOF
cp -f /root/.gemrc /etc/gemrc

View File

@ -1,6 +1,6 @@
$SNIPPET('kickstart_yum.conf')
## $SNIPPET('kickstart_centos_base_repo')
## $SNIPPET('kickstart_centos_debuginfo_repo')
## $SNIPPET('kickstart_centos_vault_repo')
$SNIPPET('kickstart_centos_base_repo')
$SNIPPET('kickstart_centos_debuginfo_repo')
$SNIPPET('kickstart_centos_vault_repo')
$SNIPPET('kickstart_yum_local_repo')

View File

@ -1,8 +1,10 @@
cat << EOF > /etc/yum.conf
[main]
cachedir=/var/cache/yum/\$basearch/\$releasever
#if $getVar('proxy', '') != ""
cachedir=/var/cache/yum/\\$basearch/\\$releasever
#if $getVar("local_repo","") == ""
#if $getVar('proxy', '') != ""
proxy=$proxy
#end if
#end if
keepcache=0
debuglevel=2

View File

@ -9,5 +9,23 @@ enabled=1
gpgcheck=0
priority=1
proxy=_none_
skip_if_unavailable=1
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
[$repo.name]
name=CentOS-6.5 - $repo.name
#if $repo.mirror_locally
baseurl=$http_server/cblr/repo_mirror/${repo.name}
#else
baseurl=${repo.mirror}
#end if
enabled=1
gpgcheck=0
priority=${repo.priority}
skip_if_unavailable=1
proxy=_none_
#end for
EOF
#end if

View File

@ -10,20 +10,25 @@
#end if
#end for
#set $proxy_url = ""
#if $getVar("local_repo","") != ""
#set $local_repo_url = $local_repo
#else
#set $local_repo_url = ""
#if $getVar("proxy","") != ""
#set $proxy_url = $proxy
#end if
#end if
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
instances=\\$(pgrep chef_client_run.sh | wc -l)
if [ \\$instances -gt 1 ]; then
echo "there are chef-client run instances '\\$instances' running" &>> /tmp/chef.log
exit 1
fi
touch /tmp/chef.log
while true; do
echo "run chef-client on \`date\`" &>> /tmp/chef.log
clients=\\$(pgrep chef-client)
if [ "\\$?" == "0" ]; then
echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
sleep 1m
break
else
echo "knife search nodes" &>> /tmp/chef.log
USER=root HOME=/root knife search node "name:\\$HOSTNAME.*" -i -a name &>> /tmp/chef.log
@ -34,16 +39,11 @@ while true; do
mkdir -p /var/log/chef/\\$node
if [ ! -f /etc/chef/\\$node.json ]; then
cat << EOL > /etc/chef/\\$node.json
#if $getVar("local_repo","") != ""
{
"local_repo": "$local_repo",
"local_repo": "$local_repo_url",
"proxy_url": "$proxy_url",
"ip_address": "$ip_address"
}
#else
{
"ip_address": "$ip_address"
}
#end if
EOL
fi
if [ ! -f "/etc/chef/\\$node.pem" ]; then
@ -63,9 +63,9 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
else
chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
fi
if [ "\\$?" != "0" ]; then
echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log

View File

@ -4,20 +4,6 @@ log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
#end if
#if $getVar('proxy', '') != ""
http_proxy '$proxy'
https_proxy '$proxy'
ENV['http_proxy'] = '$proxy'
ENV['https_proxy'] = '$proxy'
ENV['HTTP_PROXY'] = '$proxy'
ENV['HTTPS_PROXY'] = '$proxy'
#if $getVar('ignore_proxy', '') != ""
#set ignore_proxy = ','.join([proxy.strip() for proxy in $ignore_proxy.split(',') if proxy.strip()])
no_proxy '$ignore_proxy'
ENV['no_proxy'] = '$ignore_proxy'
ENV['NO_PROXY'] = '$ignore_proxy'
#end if
#end if
validation_client_name 'chef-validator'
json_attribs nil
pid_file '/var/run/chef-client.pid'

View File

@ -1,14 +1,20 @@
cat << EOF > /root/.gemrc
#if $getVar("local_repo","") == "" and $getVar('proxy', '') != ""
gem: --no-ri --no-rdoc --http-proxy=$proxy
#else
gem: --no-ri --no-rdoc
#end if
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
## - http://gems.rubyforge.org/
#if $getVar("local_repo","") != ""
- $local_repo/gem_repo/
#else
- https://rubygems.org/
#end if
:update_sources: true
:verbose: true
EOF
cp -f /root/.gemrc /etc/gemrc

View File

@ -1,34 +1,45 @@
cat << EOF > /etc/apt/apt.conf
#if $getVar('proxy', '') != ''
#if $getVar("local_repo","") == ""
#if $getVar('proxy', '') != ''
Acquire::http::Proxy "$proxy";
#end if
#end if
EOF
cat << EOF > /etc/apt/sources.list
#if $getVar('os_version', '') != ''
#if $getVar("local_repo","") != ""
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
#for $dist in $repo.apt_dists
#set $comps = " ".join($repo.apt_components)
#if $repo.comment != ""
# ${repo.comment}
#end if
#if $repo.arch == "x86_64"
#set $rarch = "[arch=amd64]"
#else
#set $rarch = "[arch=%s]" % $repo.arch
#end if
#if $repo.mirror_locally
deb ${rarch} http://$http_server/cblr/repo_mirror/${repo.name} $dist $comps
#else
deb ${rarch} ${repo.mirror} $dist $comps
#end if
#end for
#end for
#if $arch == "x86_64"
#set $rarch = "[arch=amd64]"
#else
#set $rarch = "[arch=%s]" % $arch
#end if
deb ${rarch} $local_repo/apt_repo/ubuntu/$arch/12.04/ compass_repo main
#else
#if $getVar('os_version', '') != ''
deb http://archive.ubuntu.com/ubuntu/ $os_version main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${os_version}-backports main restricted universe multiverse
#end if
#end if
#set $repo_data = $getVar("repo_data",[])
#for $repo in $repo_data
#for $dist in $repo.apt_dists
#set $comps = " ".join($repo.apt_components)
#if $repo.comment != ""
# ${repo.comment}
#end if
#if $repo.arch == "x86_64"
#set $rarch = "[arch=amd64]"
#else
#set $rarch = "[arch=%s]" % $repo.arch
#end if
#if $repo.mirror_locally
deb ${rarch} http://$http_server/cblr/repo_mirror/${repo.name} $dist $comps
#else
deb ${rarch} ${repo.mirror} $dist $comps
#end if
#end for
#end for
EOF