From 139dfc837533e40ca3336d3422a960feb946ef17 Mon Sep 17 00:00:00 2001 From: Zhe Jiang Date: Fri, 10 Jul 2015 15:00:06 +0800 Subject: [PATCH] Add recipe for serial console proxy This recipe is used to setup nova-serialproxy service. Closes-bug: #1472152 Change-Id: I044bb6d65dad849fdc0612e197c5e33b26ddddd0 --- README.md | 5 +++++ attributes/default.rb | 4 ++++ metadata.rb | 3 ++- recipes/serialproxy.rb | 39 +++++++++++++++++++++++++++++++++ spec/serialproxy-redhat_spec.rb | 28 +++++++++++++++++++++++ spec/serialproxy_spec.rb | 28 +++++++++++++++++++++++ 6 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 recipes/serialproxy.rb create mode 100644 spec/serialproxy-redhat_spec.rb create mode 100644 spec/serialproxy_spec.rb diff --git a/README.md b/README.md index e11cc7f1..d8ffb64e 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,11 @@ vncproxy - Includes recipe `nova-common` - Installs and configures the vncproxy service for console access to VMs +serialproxy +---- +- Includes recipe `nova-common` +- Installs and configures the serialproxy service for serial console access to VMs + Attributes ========== diff --git a/attributes/default.rb b/attributes/default.rb index e0548428..de78b12b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -521,6 +521,8 @@ when 'fedora', 'rhel', 'suse' # :pragma-foodcritic: ~FC024 - won't fix this 'compute_vncproxy_service' => 'openstack-nova-novncproxy', 'compute_vncproxy_consoleauth_packages' => ['openstack-nova-console'], 'compute_vncproxy_consoleauth_service' => 'openstack-nova-consoleauth', + 'compute_serialproxy_packages' => ['openstack-nova-serialproxy'], + 'compute_serialproxy_service' => 'openstack-nova-serialproxy', 'libvirt_packages' => ['libvirt', 'device-mapper', 'python-libguestfs'], 'libvirt_service' => 'libvirtd', 'libvirt_ceph_packages' => ['ceph-common'], @@ -573,6 +575,8 @@ when 'debian' 'compute_vncproxy_service' => 'nova-novncproxy', 'compute_vncproxy_consoleauth_packages' => ['nova-consoleauth'], 'compute_vncproxy_consoleauth_service' => 'nova-consoleauth', + 'compute_serialproxy_packages' => ['nova-serialproxy'], + 'compute_serialproxy_service' => 'nova-serialproxy', 'libvirt_packages' => ['libvirt-bin', 'python-guestfs'], 'libvirt_service' => 'libvirt-bin', 'libvirt_ceph_packages' => ['ceph-common'], diff --git a/metadata.rb b/metadata.rb index 86a48bf0..fc1efe56 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'opscode-chef-openstack@googlegroups.com' license 'Apache 2.0' description 'The OpenStack Compute service Nova.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '11.0.0' +version '11.1.0' recipe 'openstack-compute::api-ec2', 'Installs AWS EC2 compatible API' recipe 'openstack-compute::api-metadata', 'Installs the nova metadata package' @@ -21,6 +21,7 @@ recipe 'openstack-compute::nova-common', 'Builds the basic nova.conf config file recipe 'openstack-compute::nova-setup', 'Sets up the nova database on the mysql server, including the initial schema and subsequent creation of the appropriate networks' recipe 'openstack-compute::scheduler', 'Installs nova scheduler service' recipe 'openstack-compute::vncproxy', 'Installs and configures the vncproxy service for console access to VMs' +recipe 'openstack-compute::serialproxy', 'Installs and configures the serialproxy service for serial console access to VMs' %w(ubuntu fedora redhat centos suse).each do |os| supports os diff --git a/recipes/serialproxy.rb b/recipes/serialproxy.rb new file mode 100644 index 00000000..9aa39294 --- /dev/null +++ b/recipes/serialproxy.rb @@ -0,0 +1,39 @@ +# encoding: UTF-8 +# +# Cookbook Name:: openstack-compute +# Recipe:: serialproxy +# +# 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 'openstack-compute::nova-common' + +platform_options = node['openstack']['compute']['platform'] + +platform_options['compute_serialproxy_packages'].each do |pkg| + package pkg do + options platform_options['package_overrides'] + + action :upgrade + end +end + +proxy_service = platform_options['compute_serialproxy_service'] + +service proxy_service do + service_name proxy_service + supports status: true, restart: true + subscribes :restart, resources('template[/etc/nova/nova.conf]') + + action [:enable, :start] +end diff --git a/spec/serialproxy-redhat_spec.rb b/spec/serialproxy-redhat_spec.rb new file mode 100644 index 00000000..1c8d24af --- /dev/null +++ b/spec/serialproxy-redhat_spec.rb @@ -0,0 +1,28 @@ +# encoding: UTF-8 + +require_relative 'spec_helper' + +describe 'openstack-compute::serialproxy' do + describe 'redhat' do + let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } + let(:node) { runner.node } + let(:chef_run) { runner.converge(described_recipe) } + + include_context 'compute_stubs' + include_examples 'expect_runs_nova_common_recipe' + include_examples 'expect_creates_nova_state_dir' + include_examples 'expect_creates_nova_lock_dir' + + it 'upgrades nova serialproxy package' do + expect(chef_run).to upgrade_package('openstack-nova-serialproxy') + end + + it 'starts nova serialproxy' do + expect(chef_run).to start_service('openstack-nova-serialproxy') + end + + it 'starts nova serialproxy on boot' do + expect(chef_run).to enable_service('openstack-nova-serialproxy') + end + end +end diff --git a/spec/serialproxy_spec.rb b/spec/serialproxy_spec.rb new file mode 100644 index 00000000..2f610d86 --- /dev/null +++ b/spec/serialproxy_spec.rb @@ -0,0 +1,28 @@ +# encoding: UTF-8 + +require_relative 'spec_helper' + +describe 'openstack-compute::serialproxy' do + describe 'ubuntu' do + let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) } + let(:node) { runner.node } + let(:chef_run) { runner.converge(described_recipe) } + + include_context 'compute_stubs' + include_examples 'expect_runs_nova_common_recipe' + include_examples 'expect_creates_nova_state_dir' + include_examples 'expect_creates_nova_lock_dir' + + it 'upgrades nova serialproxy packages' do + expect(chef_run).to upgrade_package('nova-serialproxy') + end + + it 'starts nova serialproxy' do + expect(chef_run).to start_service('nova-serialproxy') + end + + it 'starts nova serialproxy on boot' do + expect(chef_run).to enable_service('nova-serialproxy') + end + end +end