Lint and test-kitchen fixes
* Adds test kitchen infrastructure * Fixes lint errors produced from foodcritic
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
*.swp
|
*.swp
|
||||||
cookbooks
|
cookbooks
|
||||||
|
test/kitchen/.kitchen
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ default["enable_monit"] = false # OS provides packages
|
|||||||
default["developer_mode"] = false # we want secure passwords by default
|
default["developer_mode"] = false # we want secure passwords by default
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
# Set to some text value if you want templated config files
|
||||||
|
# to contain a custom banner at the top of the written file
|
||||||
|
default["nova"]["custom_template_banner"] = "
|
||||||
|
# This file autogenerated by Chef
|
||||||
|
# Do not edit, changes will be overwritten
|
||||||
|
"
|
||||||
|
|
||||||
# The name of the Chef role that knows about the message queue server
|
# The name of the Chef role that knows about the message queue server
|
||||||
# that Nova uses
|
# that Nova uses
|
||||||
default["nova"]["rabbit_server_chef_role"] = "rabbitmq-server"
|
default["nova"]["rabbit_server_chef_role"] = "rabbitmq-server"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ license "Apache 2.0"
|
|||||||
description "The OpenStack Compute service Nova."
|
description "The OpenStack Compute service Nova."
|
||||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||||
version "5.0.0"
|
version "5.0.0"
|
||||||
|
name "nova"
|
||||||
|
|
||||||
recipe "api-ec2", ""
|
recipe "api-ec2", ""
|
||||||
recipe "api-metadata", ""
|
recipe "api-metadata", ""
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ template "/etc/nova/api-paste.ini" do
|
|||||||
group "root"
|
group "root"
|
||||||
mode "0644"
|
mode "0644"
|
||||||
variables(
|
variables(
|
||||||
|
"custom_template_banner" => node["nova"]["custom_template_banner"],
|
||||||
"keystone_api_ipaddress" => identity_endpoint["host"],
|
"keystone_api_ipaddress" => identity_endpoint["host"],
|
||||||
"service_port" => identity_endpoint["port"],
|
"service_port" => identity_endpoint["port"],
|
||||||
"admin_port" => identity_admin_endpoint["port"],
|
"admin_port" => identity_admin_endpoint["port"],
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ template "/etc/nova/api-paste.ini" do
|
|||||||
group "root"
|
group "root"
|
||||||
mode "0644"
|
mode "0644"
|
||||||
variables(
|
variables(
|
||||||
|
"custom_template_banner" => node["nova"]["custom_template_banner"],
|
||||||
"keystone_api_ipaddress" => identity_endpoint["host"],
|
"keystone_api_ipaddress" => identity_endpoint["host"],
|
||||||
"service_port" => identity_endpoint["port"],
|
"service_port" => identity_endpoint["port"],
|
||||||
"admin_port" => identity_admin_endpoint["port"],
|
"admin_port" => identity_admin_endpoint["port"],
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ template "/etc/libvirt/libvirtd.conf" do
|
|||||||
group "root"
|
group "root"
|
||||||
mode "0644"
|
mode "0644"
|
||||||
variables(
|
variables(
|
||||||
:auth_tcp => node["nova"]["libvirt"]["auth_tcp"]
|
"custom_template_banner" => node["nova"]["custom_template_banner"],
|
||||||
|
"auth_tcp" => node["nova"]["libvirt"]["auth_tcp"]
|
||||||
)
|
)
|
||||||
notifies :restart, resources(:service => "libvirt-bin"), :immediately
|
notifies :restart, resources(:service => "libvirt-bin"), :immediately
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ template "/etc/nova/nova.conf" do
|
|||||||
group "root"
|
group "root"
|
||||||
mode "0644"
|
mode "0644"
|
||||||
variables(
|
variables(
|
||||||
|
"custom_template_banner" => node["nova"]["custom_template_banner"],
|
||||||
"use_syslog" => node["nova"]["syslog"]["use"],
|
"use_syslog" => node["nova"]["syslog"]["use"],
|
||||||
"log_facility" => node["nova"]["syslog"]["facility"],
|
"log_facility" => node["nova"]["syslog"]["facility"],
|
||||||
"sql_connection" => sql_connection,
|
"sql_connection" => sql_connection,
|
||||||
@@ -133,6 +134,7 @@ template "/root/openrc" do
|
|||||||
group "root"
|
group "root"
|
||||||
mode "0600"
|
mode "0600"
|
||||||
variables(
|
variables(
|
||||||
|
"custom_template_banner" => node["nova"]["custom_template_banner"],
|
||||||
"user" => keystone["admin_user"],
|
"user" => keystone["admin_user"],
|
||||||
"tenant" => keystone["users"][keystone["admin_user"]]["default_tenant"],
|
"tenant" => keystone["users"][keystone["admin_user"]]["default_tenant"],
|
||||||
"password" => keystone["users"][keystone["admin_user"]]["password"],
|
"password" => keystone["users"][keystone["admin_user"]]["password"],
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#
|
|
||||||
# Cookbook Name:: nova
|
|
||||||
# Recipe:: nova-scheduler-patch
|
|
||||||
#
|
|
||||||
# Copyright 2012, Rackspace US, Inc.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
|
|
||||||
include_recipe "osops-utils"
|
|
||||||
|
|
||||||
# lp:bug https://bugs.launchpad.net/nova/+bug/1007573
|
|
||||||
# affinity filters don't work if scheduler_hints is None
|
|
||||||
template "/usr/share/pyshared/nova/scheduler/filters/affinity_filter.py" do
|
|
||||||
source "patches/affinity_filter.py.2012.1+stable~20120612-3ee026e-0ubuntu1.2"
|
|
||||||
owner "root"
|
|
||||||
group "root"
|
|
||||||
mode "0644"
|
|
||||||
notifies :restart, resources(:service => "nova-scheduler"), :immediately
|
|
||||||
only_if { ::Chef::Recipe::Patch.check_package_version("nova-scheduler","2012.1+stable~20120612-3ee026e-0ubuntu1.2",node) ||
|
|
||||||
::Chef::Recipe::Patch.check_package_version("nova-scheduler","2012.1+stable~20120612-3ee026e-0ubuntu1.3",node) }
|
|
||||||
end
|
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
$DirGroup adm
|
$DirGroup adm
|
||||||
$DirCreateMode 0755
|
$DirCreateMode 0755
|
||||||
$FileGroup adm
|
$FileGroup adm
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? -%>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end -%>
|
|
||||||
############
|
############
|
||||||
# Metadata #
|
# Metadata #
|
||||||
############
|
############
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
LoadPlugin "<%= @name %>"
|
LoadPlugin "<%= @name %>"
|
||||||
|
|
||||||
<Plugin "<%= @name %>">
|
<Plugin "<%= @name %>">
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
LoadPlugin "<%= @name %>"
|
LoadPlugin "<%= @name %>"
|
||||||
|
|
||||||
<% if not @options.empty? %>
|
<% if not @options.empty? %>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
# Defaults for libvirt-bin initscript (/etc/init.d/libvirt-bin)
|
# Defaults for libvirt-bin initscript (/etc/init.d/libvirt-bin)
|
||||||
# This is a POSIX shell fragment
|
# This is a POSIX shell fragment
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%= @custom_template_banner %>
|
||||||
Host *
|
Host *
|
||||||
StrictHostKeyChecking no
|
StrictHostKeyChecking no
|
||||||
UserKnownHostsFile=/dev/null
|
UserKnownHostsFile=/dev/null
|
||||||
|
|||||||
@@ -1,7 +1,2 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= @private_key %>
|
<%= @private_key %>
|
||||||
|
|||||||
@@ -1,7 +1,2 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= @public_key %>
|
<%= @public_key %>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
# Master libvirt daemon configuration file
|
# Master libvirt daemon configuration file
|
||||||
#
|
#
|
||||||
@@ -149,7 +145,7 @@ auth_unix_rw = "none"
|
|||||||
# Don't do this outside of a dev/test scenario. For real world
|
# Don't do this outside of a dev/test scenario. For real world
|
||||||
# use, always enable SASL and use the GSSAPI or DIGEST-MD5
|
# use, always enable SASL and use the GSSAPI or DIGEST-MD5
|
||||||
# mechanism in /etc/sasl2/libvirt.conf
|
# mechanism in /etc/sasl2/libvirt.conf
|
||||||
auth_tcp = "<%= node["nova"]["libvirt"]["auth_tcp"] %>"
|
auth_tcp = "<%= @auth_tcp %>"
|
||||||
|
|
||||||
# Change the authentication scheme for TLS sockets.
|
# Change the authentication scheme for TLS sockets.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<%= @custom_template_banner %>
|
||||||
# Override the default config file
|
# Override the default config file
|
||||||
# NOTE: This setting is no longer honoured if using
|
# NOTE: This setting is no longer honoured if using
|
||||||
# systemd. Set '--config /etc/libvirt/libvirtd.conf'
|
# systemd. Set '--config /etc/libvirt/libvirtd.conf'
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
|
|
||||||
# LOGS/STATE
|
# LOGS/STATE
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
# This file autogenerated by Chef
|
<%= @custom_template_banner %>
|
||||||
# Do not edit, changes will be overwritten
|
|
||||||
<% if not node["custom_template_banner"].nil? %>
|
|
||||||
<%= node["custom_template_banner"] %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
# COMMON OPENSTACK ENVS
|
# COMMON OPENSTACK ENVS
|
||||||
export OS_USERNAME=<%= @user %>
|
export OS_USERNAME=<%= @user %>
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
# Copyright 2012, Piston Cloud Computing, Inc.
|
|
||||||
# Copyright 2012, OpenStack LLC.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
|
|
||||||
import netaddr
|
|
||||||
|
|
||||||
from nova.compute import api as compute
|
|
||||||
from nova import flags
|
|
||||||
from nova.scheduler import filters
|
|
||||||
|
|
||||||
|
|
||||||
class AffinityFilter(filters.BaseHostFilter):
|
|
||||||
def __init__(self):
|
|
||||||
self.compute_api = compute.API()
|
|
||||||
|
|
||||||
def _all_hosts(self, context):
|
|
||||||
all_hosts = {}
|
|
||||||
for instance in self.compute_api.get_all(context):
|
|
||||||
all_hosts[instance['uuid']] = instance['host']
|
|
||||||
return all_hosts
|
|
||||||
|
|
||||||
|
|
||||||
class DifferentHostFilter(AffinityFilter):
|
|
||||||
'''Schedule the instance on a different host from a set of instances.'''
|
|
||||||
|
|
||||||
def host_passes(self, host_state, filter_properties):
|
|
||||||
context = filter_properties['context']
|
|
||||||
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
|
||||||
me = host_state.host
|
|
||||||
|
|
||||||
all_hosts = self._all_hosts(context)
|
|
||||||
affinity_uuids = scheduler_hints.get('different_host', [])
|
|
||||||
if affinity_uuids:
|
|
||||||
return not any([i for i in affinity_uuids
|
|
||||||
if all_hosts.get(i) == me])
|
|
||||||
# With no different_host key
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class SameHostFilter(AffinityFilter):
|
|
||||||
'''Schedule the instance on the same host as another instance in a set of
|
|
||||||
of instances.
|
|
||||||
'''
|
|
||||||
|
|
||||||
def host_passes(self, host_state, filter_properties):
|
|
||||||
context = filter_properties['context']
|
|
||||||
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
|
||||||
me = host_state.host
|
|
||||||
|
|
||||||
all_hosts = self._all_hosts(context)
|
|
||||||
affinity_uuids = scheduler_hints.get('same_host', [])
|
|
||||||
if affinity_uuids:
|
|
||||||
return any([i for i in affinity_uuids
|
|
||||||
if all_hosts.get(i) == me])
|
|
||||||
# With no same_host key
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleCIDRAffinityFilter(AffinityFilter):
|
|
||||||
def host_passes(self, host_state, filter_properties):
|
|
||||||
scheduler_hints = filter_properties.get('scheduler_hints') or {}
|
|
||||||
|
|
||||||
affinity_cidr = scheduler_hints.get('cidr', '/24')
|
|
||||||
affinity_host_addr = scheduler_hints.get('build_near_host_ip')
|
|
||||||
if affinity_host_addr:
|
|
||||||
affinity_net = netaddr.IPNetwork(str.join('', (affinity_host_addr,
|
|
||||||
affinity_cidr)))
|
|
||||||
return netaddr.IPAddress(flags.FLAGS.my_ip) in affinity_net
|
|
||||||
|
|
||||||
# We don't have an affinity host address.
|
|
||||||
return True
|
|
||||||
4
test/kitchen/Kitchenfile
Normal file
4
test/kitchen/Kitchenfile
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
cookbook "cookbook-nova" do
|
||||||
|
lint(:ignore => ["FC024"])
|
||||||
|
runtimes []
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user