This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add classes to create Mongo, Redis, AMQP, Carrot, MySQL, and Postgresql connections to CF services - Fix auto-reconfig log messages if 0 or more than one services of a type are found - Add cfruntime rdoc - Move supported version constants to AutoReconfiguration module - Remove complex passing of URL argument during AMQP auto-config - Null path option during Redis auto-config Change-Id: Iccab8a424dbb6e73b94feb6057859e17020005c5
- Loading branch information
Jennifer Hickey
committed
Dec 16, 2011
1 parent
25777a8
commit af46612
Showing
37 changed files
with
1,042 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,2 @@ | |||
# Copyright (c) 2009-2011 VMware, Inc. | |||
require 'cfautoconfig/configurer' | require 'cfautoconfig/configurer' | ||
require 'cfautoconfig/version' | require 'cfautoconfig/version' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,29 +1,24 @@ | |||
require 'cfruntime/properties' | require 'cfruntime/properties' | ||
require 'cfruntime/redis' | |||
|
|
||
module AutoReconfiguration | module AutoReconfiguration | ||
module Redis | SUPPORTED_REDIS_VERSION = '2.0' | ||
def self.included( base ) | module Redis | ||
base.send( :alias_method, :original_initialize, :initialize) | def self.included( base ) | ||
base.send( :alias_method, :initialize, :initialize_with_cf ) | base.send( :alias_method, :original_initialize, :initialize) | ||
end | base.send( :alias_method, :initialize, :initialize_with_cf ) | ||
end | |||
|
|
||
def initialize_with_cf(options = {}) | def initialize_with_cf(options = {}) | ||
service_props = CFRuntime::CloudApp.service_props('redis') | service_names = CFRuntime::CloudApp.service_names_of_type('redis') | ||
if(service_props.nil?) | if service_names.length == 1 | ||
puts "No Redis service bound to app. Skipping auto-reconfiguration." | puts "Auto-reconfiguring Redis." | ||
original_initialize options | cfoptions = CFRuntime::RedisClient.options_for_svc(service_names[0],options) | ||
else | original_initialize cfoptions | ||
puts "Auto-reconfiguring Redis." | else | ||
cfoptions = options | puts "Found #{service_names.length} redis services. Skipping auto-reconfiguration." | ||
if !cfoptions[:path].nil? | original_initialize options | ||
#Host and port are ignored if a path is specified | end | ||
cfoptions[:path] = "#{service_props[:host]}:#{service_props[:port]}" | end | ||
end | end | ||
cfoptions[:host] = service_props[:host] | |||
cfoptions[:port] = service_props[:port] | |||
cfoptions[:password] = service_props[:password] | |||
original_initialize cfoptions | |||
end | |||
end | |||
end | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,39 +1,30 @@ | |||
require 'cfruntime/properties' | require 'cfruntime/properties' | ||
require 'cfruntime/amqp' | |||
|
|
||
module AutoReconfiguration | module AutoReconfiguration | ||
module AMQP | SUPPORTED_AMQP_VERSION = '0.8' | ||
def self.included( base ) | module AMQP | ||
base.send( :alias_method, :original_connect, :connect) | def self.included( base ) | ||
base.send( :alias_method, :connect, :connect_with_cf ) | base.send( :alias_method, :original_connect, :connect) | ||
end | base.send( :alias_method, :connect, :connect_with_cf ) | ||
end | |||
|
|
||
def connect_with_cf(connection_options_or_string = {}, other_options = {}, &block) | def connect_with_cf(connection_options_or_string = {}, other_options = {}, &block) | ||
service_props = CFRuntime::CloudApp.service_props('rabbitmq') | service_names = CFRuntime::CloudApp.service_names_of_type('rabbitmq') | ||
if(service_props.nil?) | if service_names.length == 1 | ||
puts "No RabbitMQ service bound to app. Skipping auto-reconfiguration." | puts "Auto-reconfiguring AMQP." | ||
original_connect(connection_options_or_string, other_options, &block) | case connection_options_or_string | ||
else | when String then | ||
puts "Auto-reconfiguring AMQP." | cfoptions = {} | ||
url_provided = false | else | ||
case connection_options_or_string | cfoptions = connection_options_or_string | ||
when String then | end | ||
url_provided = true | original_connect(CFRuntime::AMQPClient.options_for_svc(service_names[0],cfoptions), | ||
cfoptions = {} | other_options, &block) | ||
else | else | ||
cfoptions = connection_options_or_string | puts "Found #{service_names.length} rabbitmq services. Skipping auto-reconfiguration." | ||
end | original_connect(connection_options_or_string, other_options, &block) | ||
if service_props[:url] && url_provided | end | ||
#If user passed in a URL and we have a URL for service, use it | end | ||
original_connect(service_props[:url], other_options, &block) | end | ||
else | |||
cfoptions[:host] = service_props[:host] | |||
cfoptions[:port] = service_props[:port] | |||
cfoptions[:user] = service_props[:username] | |||
cfoptions[:pass] = service_props[:password] | |||
cfoptions[:vhost] = service_props[:vhost] | |||
original_connect(cfoptions, other_options, &block) | |||
end | |||
end | |||
end | |||
end | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 19 additions & 22 deletions
41
auto-reconfiguration/lib/cfautoconfig/messaging/carrot.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,27 +1,24 @@ | |||
require 'cfruntime/properties' | require 'cfruntime/properties' | ||
require 'cfruntime/carrot' | |||
|
|
||
module AutoReconfiguration | module AutoReconfiguration | ||
module Carrot | SUPPORTED_CARROT_VERSION = '1.0' | ||
def self.included( base ) | module Carrot | ||
base.send( :alias_method, :original_initialize, :initialize) | def self.included( base ) | ||
base.send( :alias_method, :initialize, :initialize_with_cf ) | base.send( :alias_method, :original_initialize, :initialize) | ||
end | base.send( :alias_method, :initialize, :initialize_with_cf ) | ||
end | |||
|
|
||
def initialize_with_cf(opts = {}) | def initialize_with_cf(opts = {}) | ||
service_props = CFRuntime::CloudApp.service_props('rabbitmq') | service_names = CFRuntime::CloudApp.service_names_of_type('rabbitmq') | ||
if(service_props.nil?) | if service_names.length == 1 | ||
puts "No RabbitMQ service bound to app. Skipping auto-reconfiguration." | puts "Auto-reconfiguring Carrot." | ||
original_initialize opts | cfopts = CFRuntime::CarrotClient.options_for_svc(service_names[0],opts) | ||
else | original_initialize cfopts | ||
puts "Auto-reconfiguring Carrot." | else | ||
cfoptions = opts | puts "Found #{service_names.length} rabbitmq services. Skipping auto-reconfiguration." | ||
cfoptions[:host] = service_props[:host] | original_initialize opts | ||
cfoptions[:port] = service_props[:port] | end | ||
cfoptions[:user] = service_props[:username] | end | ||
cfoptions[:pass] = service_props[:password] | end | ||
cfoptions[:vhost] = service_props[:vhost] | |||
original_initialize opts | |||
end | |||
end | |||
end | |||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.