Module: Befog::Commands::Mixins::Scope
- Defined in:
- lib/befog/commands/mixins/scope.rb
Instance Method Summary collapse
- #_bank ⇒ Object
- #account_key ⇒ Object
- #account_secret ⇒ Object
- #bank ⇒ Object
- #bank? ⇒ Boolean
- #bank_name ⇒ Object
- #banks ⇒ Object
-
#compute ⇒ Object
TODO: do something clever once we have more than 2-3 providers.
- #flavor ⇒ Object
- #flavor? ⇒ Boolean
- #get_server(id) ⇒ Object
- #image ⇒ Object
- #image? ⇒ Boolean
- #keypair ⇒ Object
- #keypair? ⇒ Boolean
- #price ⇒ Object
- #provider ⇒ Object
- #provider? ⇒ Boolean
- #provider_name ⇒ Object
- #providers ⇒ Object
- #region ⇒ Object
- #region? ⇒ Boolean
- #security_group ⇒ Object
- #security_group? ⇒ Boolean
- #servers ⇒ Object
- #servers=(array) ⇒ Object
Instance Method Details
#_bank ⇒ Object
105 106 107 |
# File 'lib/befog/commands/mixins/scope.rb', line 105 def _bank banks[bank_name] ||= {} end |
#account_key ⇒ Object
25 26 27 |
# File 'lib/befog/commands/mixins/scope.rb', line 25 def account_key provider["key"] end |
#account_secret ⇒ Object
29 30 31 |
# File 'lib/befog/commands/mixins/scope.rb', line 29 def account_secret provider["secret"] end |
#bank ⇒ Object
109 110 111 |
# File 'lib/befog/commands/mixins/scope.rb', line 109 def bank _bank["configuration"] ||= {} end |
#bank? ⇒ Boolean
113 114 115 |
# File 'lib/befog/commands/mixins/scope.rb', line 113 def bank? !![:bank] end |
#bank_name ⇒ Object
117 118 119 |
# File 'lib/befog/commands/mixins/scope.rb', line 117 def bank_name [:bank] or error("Did you mean to include a bank name?") end |
#banks ⇒ Object
101 102 103 |
# File 'lib/befog/commands/mixins/scope.rb', line 101 def banks configuration["banks"] ||= {} end |
#compute ⇒ Object
TODO: do something clever once we have more than 2-3 providers
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/befog/commands/mixins/scope.rb', line 34 def compute case provider_name when "aws" @compute ||= Fog::Compute.new(:provider => "AWS", :aws_access_key_id => account_key, :aws_secret_access_key => account_secret, :region => region) else error("Provider '#{provider_name}' is currently unsupported.") end end |
#flavor ⇒ Object
60 61 62 63 |
# File 'lib/befog/commands/mixins/scope.rb', line 60 def flavor [:type] or bank["type"] or error("Specify an instance type (flavor) with --type or by adding one to the '#{bank_name}' bank.") end |
#flavor? ⇒ Boolean
65 66 67 |
# File 'lib/befog/commands/mixins/scope.rb', line 65 def flavor? !![:type] or bank["type"] end |
#get_server(id) ⇒ Object
46 47 48 |
# File 'lib/befog/commands/mixins/scope.rb', line 46 def get_server(id) compute.servers.get(id) end |
#image ⇒ Object
69 70 71 72 |
# File 'lib/befog/commands/mixins/scope.rb', line 69 def image [:image] or bank["image"] or error("Specify an image with --image or by adding one to the '#{bank_name}' bank.") end |
#image? ⇒ Boolean
74 75 76 |
# File 'lib/befog/commands/mixins/scope.rb', line 74 def image? !![:image] or bank["image"] end |
#keypair ⇒ Object
87 88 89 90 |
# File 'lib/befog/commands/mixins/scope.rb', line 87 def keypair [:keypair] or bank["keypair"] or error("Specify a keypair with --keypair or by adding one to the '#{bank_name}' bank.") end |
#keypair? ⇒ Boolean
97 98 99 |
# File 'lib/befog/commands/mixins/scope.rb', line 97 def keypair? !![:keypair] or bank["keypair"] end |
#price ⇒ Object
92 93 94 95 |
# File 'lib/befog/commands/mixins/scope.rb', line 92 def price [:price] or bank["price"] or error("Specify a spot instance price with --price or by adding one to the '#{bank_name}' bank.") end |
#provider ⇒ Object
21 22 23 |
# File 'lib/befog/commands/mixins/scope.rb', line 21 def provider @provider ||= (providers[provider_name] ||= {}) end |
#provider? ⇒ Boolean
13 14 15 |
# File 'lib/befog/commands/mixins/scope.rb', line 13 def provider? !![:provider] or bank["provider"] end |
#provider_name ⇒ Object
8 9 10 11 |
# File 'lib/befog/commands/mixins/scope.rb', line 8 def provider_name [:provider] or bank["provider"] or error("Specify a provider with --provider or by adding one to the '#{bank_name}' bank.") end |
#providers ⇒ Object
17 18 19 |
# File 'lib/befog/commands/mixins/scope.rb', line 17 def providers @providers ||= (configuration["providers"] ||= {}) end |
#region ⇒ Object
51 52 53 54 |
# File 'lib/befog/commands/mixins/scope.rb', line 51 def region [:region] or bank["region"] or error("Specify a region with --region or by adding one to the '#{bank_name}' bank.") end |
#region? ⇒ Boolean
56 57 58 |
# File 'lib/befog/commands/mixins/scope.rb', line 56 def region? !![:region] or bank["region"] end |
#security_group ⇒ Object
78 79 80 81 |
# File 'lib/befog/commands/mixins/scope.rb', line 78 def security_group [:group] or bank["group"] or error("Specify a security group with --group or by adding one to the '#{bank_name}' bank.") end |
#security_group? ⇒ Boolean
83 84 85 |
# File 'lib/befog/commands/mixins/scope.rb', line 83 def security_group? [:group] or bank["group"] end |
#servers ⇒ Object
121 122 123 |
# File 'lib/befog/commands/mixins/scope.rb', line 121 def servers _bank["servers"] ||= [] end |
#servers=(array) ⇒ Object
125 126 127 |
# File 'lib/befog/commands/mixins/scope.rb', line 125 def servers=(array) _bank["servers"] = array end |