Added identity_registration recipe

Added recipe necessary for metering service & endpoints registration.

Change-Id: Iaa8c4f31dffcb85395bf2fedba8f294849fa0697
This commit is contained in:
John Dewey 2013-08-07 22:40:42 -07:00
parent 100260a704
commit 2f736dd4d4
8 changed files with 113 additions and 2 deletions

View File

@ -2,3 +2,5 @@ metadata
cookbook "openstack-common",
git: "git://github.com/stackforge/cookbook-openstack-common.git"
cookbook "openstack-identity",
git: "git://github.com/stackforge/cookbook-openstack-identity.git"

View File

@ -4,9 +4,14 @@
"path": "."
},
"openstack-common": {
"locked_version": "0.3.5",
"locked_version": "0.4.3",
"git": "git://github.com/stackforge/cookbook-openstack-common.git",
"ref": "4af229d56319b44945fe9e8ebd2ab2aa87b29c83"
"ref": "eb5eed7126b6a6efbaf803e8a594d610cf661e97"
},
"openstack-identity": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-identity.git",
"ref": "b881af26095cfa869a6970067c49597a0ee63586"
},
"apt": {
"locked_version": "2.0.0"

View File

@ -36,6 +36,10 @@ common
----
- Common metering configuration.
identity_registration
----
- Registers the endpoints with Keystone.
Attributes
==========

View File

@ -43,6 +43,8 @@ default["openstack"]["metering"]["api"]["auth"]["cache_dir"] = "/var/cache/ceilo
default["openstack"]["metering"]["user"] = "ceilometer"
default["openstack"]["metering"]["group"] = "ceilometer"
default["openstack"]["metering"]["region"] = "RegionOne"
case platform
when "suse" # :pragma-foodcritic: ~FC024 - won't fix this
default["openstack"]["metering"]["platform"] = {

View File

@ -11,9 +11,11 @@ recipe "openstack-metering::agent-compute", "Installs agent compute service."
recipe "openstack-metering::api", "Installs API service."
recipe "openstack-metering::collector", "Installs nova network service."
recipe "openstack-metering::common", "Common metering configuration."
recipe "openstack-metering::identity_registration", "Registers the endpoints with Keystone"
%w{ ubuntu suse }.each do |os|
supports os
end
depends "openstack-common", "~> 0.4.0"
depends "openstack-identity", "~> 7.0.0"

View File

@ -0,0 +1,51 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: identity_registration
#
# Copyright 2013, AT&T Services, 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.
#
require "uri"
class ::Chef::Recipe
include ::Openstack
end
api_endpoint = endpoint "metering-api"
identity_admin_endpoint = endpoint "identity-admin"
bootstrap_token = secret "secrets", "openstack_identity_bootstrap_token"
auth_uri = ::URI.decode identity_admin_endpoint.to_s
openstack_identity_register "Register Metering Service" do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_name "ceilometer"
service_type "metering"
service_description "Ceilometer Service"
action :create_service
end
openstack_identity_register "Register Metering Endpoint" do
auth_uri auth_uri
bootstrap_token bootstrap_token
service_type "metering"
endpoint_region node["openstack"]["metering"]["region"]
endpoint_adminurl ::URI.decode api_endpoint.to_s
endpoint_internalurl ::URI.decode api_endpoint.to_s
endpoint_publicurl ::URI.decode api_endpoint.to_s
action :create_endpoint
end

View File

@ -0,0 +1,42 @@
require_relative "spec_helper"
describe "openstack-metering::identity_registration" do
before do
metering_stubs
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-metering::identity_registration"
end
it "registers metering service" do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Metering Service"
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_name => "ceilometer",
:service_type => "metering",
:action => [:create_service]
)
end
it "registers metering endpoint" do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Metering Endpoint"
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_type => "metering",
:endpoint_region => "RegionOne",
:endpoint_adminurl => "http://127.0.0.1:8777/v1",
:endpoint_internalurl => "http://127.0.0.1:8777/v1",
:endpoint_publicurl => "http://127.0.0.1:8777/v1",
:action => [:create_endpoint]
)
end
end

View File

@ -25,6 +25,9 @@ def metering_stubs
::Chef::Recipe.any_instance.stub(:user_password).
with("guest").
and_return "rabbit-pass"
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "openstack_identity_bootstrap_token").
and_return "bootstrap-token"
end
def expect_runs_common_recipe