Permalink
Browse files

Updates to support Ruby 1.9.2.

  • Loading branch information...
1 parent c6c5e58 commit b3b811989a871730f6f347e8f0c3c88042e26e68 Dan Prince committed Apr 16, 2011
View
@@ -1,3 +1,6 @@
+* Thu Apr 16 2011 Dan Prince <dan.prince@rackspace.com> - 2.5.1
+ - Updates to support Ruby 1.9.2.
+
* Thu Apr 14 2011 Dan Prince <dan.prince@rackspace.com> - 2.5.0
- Make /root/cookbook-repos on the Chef server if it doesn't exist.
- Add cache_file option to the VPC Client class.
View
@@ -1 +1 @@
-2.5.0
+2.5.1
@@ -19,6 +19,16 @@ def self.load_configs
end
+def self.get_cookbook_repos(options)
+ cookbook_repos_config=options["chef_cookbook_repos"]
+ return "" if cookbook_repos_config.nil?
+ if cookbook_repos_config.respond_to?(:inject) then
+ return options["chef_cookbook_repos"].inject { |sum, c| sum + " " + c }
+ else
+ return cookbook_repos_config.to_s
+ end
+end
+
# validate the chef.json config file by parsing it
def self.validate_json(options)
@@ -65,10 +75,7 @@ def self.install_chef_server(options, machine_os_types)
knife_add_nodes_script+="knife_add_node '#{node_name}' '#{run_list}' '#{attributes}'\n"
end
-cookbook_urls=""
-if options["chef_cookbook_repos"] then
- cookbook_urls=options["chef_cookbook_repos"].inject { |sum, c| sum + " " + c }
-end
+cookbook_urls=self.get_cookbook_repos(options)
os_type=machine_os_types[options['chef_server_name']]
data=%x{
@@ -254,10 +261,7 @@ def self.rsync_cookbook_repos(options, local_dir="#{CHEF_VPC_PROJECT}/cookbook-r
puts "OK"
end
- cookbook_urls=""
- if options["chef_cookbook_repos"] then
- cookbook_urls=options["chef_cookbook_repos"].inject { |sum, c| sum + " " + c }
- end
+ cookbook_urls=self.get_cookbook_repos(options)
data=%x{
ssh -o "StrictHostKeyChecking no" root@#{options['ssh_gateway_ip']} bash <<-"EOF_SSH"
@@ -25,10 +25,18 @@ def initialize(options={})
@id=options[:id].to_i
@name=options[:name]
@description=options[:description]
+ if options[:status]
+ @status=options[:status]
+ else
+ @status = "Pending"
+ end
@status=options[:status] or @status = "Pending"
@server_group_id=options[:server_group_id]
- @cache_file=options[:cache_file] or options[:server_group_id]
-
+ if options[:cache_file] then
+ @cache_file=options[:cache_file]
+ else
+ @cache_file=options[:server_group_id]
+ end
@vpn_network_interfaces=[]
end
@@ -52,17 +60,16 @@ def delete
end
def self.from_xml(xml)
-
client=nil
dom = REXML::Document.new(xml)
- REXML::XPath.each(dom, "/client") do |client|
+ REXML::XPath.each(dom, "/client") do |cxml|
client=Client.new(
- :id => XMLUtil.element_text(client,"id").to_i,
- :name => XMLUtil.element_text(client, "name"),
- :description => XMLUtil.element_text(client,"description"),
- :status => XMLUtil.element_text(client,"status"),
- :server_group_id => XMLUtil.element_text(client, "server-group-id").to_i
+ :id => XMLUtil.element_text(cxml,"id").to_i,
+ :name => XMLUtil.element_text(cxml, "name"),
+ :description => XMLUtil.element_text(cxml,"description"),
+ :status => XMLUtil.element_text(cxml,"status"),
+ :server_group_id => XMLUtil.element_text(cxml, "server-group-id").to_i
)
REXML::XPath.each(dom, "//vpn-network-interface") do |vni|
vni = VpnNetworkInterface.new(
@@ -75,10 +82,8 @@ def self.from_xml(xml)
)
client.vpn_network_interfaces << vni
end
- end
-
+ end
client
-
end
def to_xml
@@ -222,7 +222,7 @@ namespace :chef do
timeout=ENV['CHEF_TIMEOUT']
group=ServerGroup.fetch(:source => "cache")
if server_list.nil? or server_list.empty?
- server_list=group.server_names.collect{|x| x+" "}.to_s
+ server_list=group.server_names.collect{|x| x+" "}.join.to_s
end
if timeout.nil? or timeout.empty?
timeout=600
@@ -341,7 +341,7 @@ namespace :vpn do
vpn_client_name=configs['vpn_client_name']
end
- client=Client.create(group, vpn_client_name)
+ client=Client.create(group, vpn_client_name, true)
puts "Client ID #{client.id} created."
end
View
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/test_helper'
+$:.unshift File.dirname(__FILE__)
+require 'test_helper'
module ChefVPCToolkit
module CloudServersVPC
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/test_helper'
+$:.unshift File.dirname(__FILE__)
+require 'test_helper'
require 'fileutils'
require 'tempfile'
View
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/test_helper'
+$:.unshift File.dirname(__FILE__)
+require 'test_helper'
module ChefVPCToolkit
module CloudServersVPC
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/test_helper'
+$:.unshift File.dirname(__FILE__)
+require 'test_helper'
require 'tempfile'
View
@@ -3,9 +3,8 @@
require 'mocha'
CHEF_VPC_PROJECT = "#{File.dirname(__FILE__)}" unless defined?(CHEF_VPC_PROJECT)
-Dir[File.join(File.dirname(__FILE__), '/../lib', '*.rb')].each do |lib|
- require(lib)
-end
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require 'chef-vpc-toolkit'
require 'tempfile'
require 'fileutils'
View
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/test_helper'
+$:.unshift File.dirname(__FILE__)
+require 'test_helper'
module ChefVPCToolkit
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/test_helper'
+$:.unshift File.dirname(__FILE__)
+require 'test_helper'
require 'tempfile'

0 comments on commit b3b8119

Please sign in to comment.