Permalink
Browse files

Merge pull request #61 from seomoz/project_name

Project name (wip)
  • Loading branch information...
2 parents f1e1532 + bb5f4bb commit 14a73ebfb965cca1cdf180cdcca90a24683fd253 @delano delano committed Jun 1, 2011
View
@@ -42,6 +42,7 @@ class RudyCLI < Rudy::CLI::Base
global :t, :testrun, "Test run. Don't execute action (PARTIALLY SUPPORTED)."
global :P, :parallel, "Execute remote commands in parallel (PARTIALLY SUPPORTED)."
global :F, :force, "Force an action despite warnings"
+ global :p, :project, String, "Project name. Used in group and machine names."
global :positions, Integer, "Override positions number for the current role"
View
@@ -56,7 +56,7 @@ def Rudy.sysinfo
end
def sysinfo; Rudy.sysinfo; end
- unless defined? Rudy::DOMAIN # We can assume all constants are defined
+ unless defined? Rudy::DEFAULT_DOMAIN # We can assume all constants are defined
@@quiet = false
@@auto = false
@@ -65,7 +65,7 @@ def sysinfo; Rudy.sysinfo; end
# SimpleDB accepts dashes in the domain name on creation and with the query syntax.
# However, with select syntax it says: "The specified query expression syntax is not valid"
- DOMAIN = "rudy_state".freeze
+ DEFAULT_DOMAIN = "rudy_state".freeze
DELIM = '-'.freeze
CONFIG_DIR = File.join(Rudy.sysinfo.home, '.rudy').freeze
View
@@ -1,5 +1,4 @@
-
module Rudy
module CLI
class Machines < Rudy::CLI::CommandBase
View
@@ -43,6 +43,7 @@ class Global < Storable
field :bucket
field :positions
+ field :project
attr_accessor :print_header
@@ -73,7 +74,7 @@ def apply_config(config)
# value from the defaults config.
# WARNING: Don't add bucket either or any machines configuration param
# TODO: investigate removing this apply_config method
- %w[region zone environment role position bucket
+ %w[region zone environment role position bucket project
localhost nocolor quiet auto force parallel].each do |name|
curval, defval = self.send(name), config.defaults.send(name)
if curval.nil? && !defval.nil?
View
@@ -48,16 +48,17 @@ def self.reset_global; @@global = Rudy::Global.new; end
def self.create_domain
@sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
- @sdb.create_domain Rudy::DOMAIN
+ @sdb.create_domain self.domain
end
def self.domain_exists?
@sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region)
- (@sdb.list_domains || []).member? Rudy::DOMAIN
+ (@sdb.list_domains || []).member? self.domain
end
def self.domain
- Rudy::DOMAIN
+ name = @@global.project.to_s.gsub(/\W/, '_').downcase
+ [name, Rudy::DEFAULT_DOMAIN].join('_')
end
# Puts +msg+ to +@@logger+
@@ -167,7 +168,7 @@ def defined_keypairpath(name=nil)
def current_machine_group
- [@@global.environment, @@global.role].join(Rudy::DELIM)
+ [@@global.project, @@global.environment, @@global.role].compact.join(Rudy::DELIM)
end
def current_group_name
View
@@ -4,10 +4,10 @@ module Rudy
module Metadata
include Rudy::Huxtable
- COMMON_FIELDS = [:region, :zone, :environment, :role].freeze
+ COMMON_FIELDS = [:region, :zone, :project, :environment, :role].freeze
@@rsdb = nil
- @@domain = Rudy::DOMAIN
+ @@domain = Rudy::Huxtable.domain
#
def self.get_rclass(rtype)
@@ -45,11 +45,11 @@ def self.create_domain(n)
@@domain = n if @@rsdb.create_domain n
end
- # Destroys a SimpleDB domain named +n+ and sets +@@domain+ to Rudy::DOMAIN
+ # Destroys a SimpleDB domain named +n+ and sets +@@domain+ to Rudy::DEFAULT_DOMAIN
def self.destroy_domain(n)
Rudy::Huxtable.ld "DESTROY: #{n}" if Rudy.debug?
@@rsdb.destroy_domain n
- @@domain = Rudy::DOMAIN
+ @@domain = Rudy::DEFAULT_DOMAIN
true
end
@@ -182,8 +182,8 @@ def initialize(rtype, opts={})
end
def name(*other)
- parts = [@rtype, @zone, @environment, @role, @position, *other].flatten
- parts.join Rudy::DELIM
+ parts = [@rtype, @zone, @project, @environment, @role, @position, *other]
+ parts.compact.flatten.join Rudy::DELIM
end
def save(replace=false)
@@ -12,7 +12,7 @@
Rudy::Huxtable.global.offline = false
end
- drill "has default domain", Rudy::DOMAIN do
+ drill "has default domain", Rudy::DEFAULT_DOMAIN do
Rudy::Metadata.domain
end
@@ -28,7 +28,7 @@
dream test_domain
drill "can create test domain (automatically sets new internal domain)" do
- Rudy::Metadata.domain = Rudy::DOMAIN
+ Rudy::Metadata.domain = Rudy::DEFAULT_DOMAIN
Rudy::Metadata.create_domain test_domain
end
@@ -4,7 +4,7 @@
tryout "Disk API" do
- set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
+ set :test_domain, Rudy::DEFAULT_DOMAIN #'test_' << Rudy::Utils.strand(4)
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
setup do
@@ -5,7 +5,7 @@
tryout "Backup API" do
set :sample_time, Time.now.utc
- set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
+ set :test_domain, Rudy::DEFAULT_DOMAIN #'test_' << Rudy::Utils.strand(4)
set :test_env, :stage #'env_' << Rudy::Utils.strand(4)
setup do
@@ -5,7 +5,7 @@
tryout "Backup Snapshot API" do
set :sample_time, Time.now.utc
- set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
+ set :test_domain, Rudy::DEFAULT_DOMAIN #'test_' << Rudy::Utils.strand(4)
set :test_env, :stage #'env_' << Rudy::Utils.strand(4)
setup do
@@ -4,7 +4,7 @@
tryout "Rudy::Machine API" do
- set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
+ set :test_domain, Rudy::DEFAULT_DOMAIN #'test_' << Rudy::Utils.strand(4)
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
setup do
@@ -4,7 +4,7 @@
tryout "Rudy::Machine Instance API" do
- set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
+ set :test_domain, Rudy::DEFAULT_DOMAIN #'test_' << Rudy::Utils.strand(4)
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
setup do
@@ -5,7 +5,7 @@
tryout "Rudy::Machines API" do
- set :test_domain, Rudy::DOMAIN #'test_' << Rudy::Utils.strand(4)
+ set :test_domain, Rudy::DEFAULT_DOMAIN #'test_' << Rudy::Utils.strand(4)
set :test_env, 'stage' #'env_' << Rudy::Utils.strand(4)
setup do

0 comments on commit 14a73eb

Please sign in to comment.