lib/cap-rightscale/configuration/rightscale.rb in cap-rightscale-0.3.10 vs lib/cap-rightscale/configuration/rightscale.rb in cap-rightscale-0.3.11

- old
+ new

@@ -1,12 +1,13 @@ -require 'cap-rightscale/utils/rs_utils.rb' +require 'cap-rightscale/utils/rs_utils' require 'cap-rightscale/configuration/rightscale/resource' module Capistrano class Configuration module RightScale attr_writer :validate_echo, :use_nickname, :use_public_ip, :use_rs_cache + attr_accessor :domainname def get_rs_instance @rs_instance ||= Capistrano::RightScale::Resource.instance end @@ -32,14 +33,10 @@ def rs_cache_lifetime(time) @lifetime = time # seconds end - def domainname(domain) - @domain = domain - end - # Get RightScale Server Array # === Parameters # * _role_ - Capistrano role symbol (ex. :app, :web, :db) # * _params[:array_id]_ - ex. :array_id => 1[https://my.rightscale.com/server_arrays/{id}] # * _params[:xxx]_ - ex. :user => "www", :port => 2345, etc... @@ -71,11 +68,11 @@ deployment_name = dept.nickname logger.info("Deployment #{deployment_name}:") host_list = get_rs_instance.__send__(:array_instances, array.id).select {|i| i[:state] == "operational"}.map do |instance| hostname = instance[:nickname].sub(/ #[0-9]+$/, "-%03d" % instance[:nickname].match(/[0-9]+$/).to_s.to_i) - hostname << ".#{_domain}" if _domain && hostname.match(/#{_domain}/).nil? + hostname << ".#{domainname}" if domainname && hostname.match(/#{domainname}/).nil? ip = use_public_ip ? instance[:ip_address] : instance[:private_ip_address] logger.info("Found server: #{hostname}(#{ip})") use_nickname ? hostname : ip end @@ -126,11 +123,11 @@ srvs = dept.servers.select {|s| s[:state] == "operational"} srvs = srvs.select {|s| /#{_name_prefix}/ =~ s[:nickname]} if _name_prefix host_list = srvs.map do |server| hostname = server[:nickname] - hostname << ".#{_domain}" if _domain && hostname.match(/#{_domain}/).nil? + hostname << ".#{domainname}" if domainname && hostname.match(/#{domainname}/).nil? ip = use_public_ip ? server[:settings][:ip_address] : server[:settings][:private_ip_address] logger.info("Found server: #{hostname}(#{ip})") use_nickname ? hostname : ip end @@ -192,11 +189,11 @@ found_ids = srvs_ids & ts_ids if found_ids.size > 0 host_list = srvs.select {|s| found_ids.include?(s[:href].match(/[0-9]+$/).to_s)}.map do |server| hostname = server[:nickname] - hostname << ".#{_domain}" if _domain && hostname.match(/#{_domain}/).nil? + hostname << ".#{domainname}" if domainname && hostname.match(/#{domainname}/).nil? ip = use_public_ip ? server[:settings][:ip_address] : server[:settings][:private_ip_address] logger.info("Found server: #{hostname}(#{ip})") use_nickname ? hostname : ip end @@ -287,13 +284,9 @@ env = ENV['RSCACHE'].downcase @use_rs_cache = false if env == "false" end @use_rs_cache = true if @use_rs_cache.nil? @use_rs_cache - end - - def _domain - @domain || nil end end end end