hpcloud 2.0.6 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,14 @@ module HP
42
42
  :db,
43
43
  :network,
44
44
  :"block storage"]
45
+ # we only list whats available in connection.rb
46
+ CATALOG = [:catalog_compute,
47
+ :catalog_object_storage,
48
+ :catalog_block_storage,
49
+ :catalog_cdn,
50
+ :catalog_dns,
51
+ :catalog_load_balancer,
52
+ :catalog_networking]
45
53
  OPTIONS = [:connect_timeout,
46
54
  :read_timeout,
47
55
  :write_timeout,
@@ -68,6 +76,7 @@ module HP
68
76
  ret = ""
69
77
  CREDENTIALS.each{|key| ret += "\n * " + key.to_s }
70
78
  ZONES.each{|key| ret += "\n * " + key.to_s }
79
+ CATALOG.each{|key| ret += "\n * " + key.to_s }
71
80
  OPTIONS.each{|key| ret += "\n * " + key.to_s }
72
81
  return ret
73
82
  end
@@ -131,6 +140,7 @@ module HP
131
140
  hsh[:regions] = regions
132
141
  end
133
142
  hsh[:regions] = {} if hsh[:regions].nil?
143
+ hsh[:catalog] = {} if hsh[:catalog].nil?
134
144
  hsh[:options] = {} if hsh[:options].nil?
135
145
  @accts[account] = hsh
136
146
  rescue Exception => e
@@ -150,6 +160,7 @@ module HP
150
160
  uri = Config.new.get(:default_auth_uri)
151
161
  @accts[account] = {:credentials=>{:auth_uri=>uri},
152
162
  :regions=>{},
163
+ :catalog=>{},
153
164
  :options=>{}}
154
165
  end
155
166
  return @accts[account]
@@ -157,7 +168,7 @@ module HP
157
168
 
158
169
  def set_cred(account, cred)
159
170
  if @accts[account].nil?
160
- @accts[account] = {:credentials=>{}, :regions=>{}, :options=>{}}
171
+ @accts[account] = {:credentials=>{}, :regions=>{}, :catalog=>{}, :options=>{}}
161
172
  end
162
173
  @accts[account][:credentials] = cred
163
174
  unless cred[:hp_auth_uri].nil?
@@ -169,7 +180,7 @@ module HP
169
180
 
170
181
  def set_regions(account, regions)
171
182
  if @accts[account].nil?
172
- @accts[account] = {:credentials=>{}, :regions=>{}, :options=>{}}
183
+ @accts[account] = {:credentials=>{}, :regions=>{}, :catalog=>{}, :options=>{}}
173
184
  end
174
185
  @accts[account][:regions] = regions
175
186
  end
@@ -182,6 +193,9 @@ module HP
182
193
  hsh[:credentials][key] = value
183
194
  elsif ZONES.include?(key)
184
195
  hsh[:regions][key] = value
196
+ elsif CATALOG.include?(key)
197
+ cat_key = key.to_s.gsub(/^catalog_/,'').to_sym
198
+ hsh[:catalog][cat_key] = value
185
199
  elsif OPTIONS.include?(key)
186
200
  hsh[:options][key] = value
187
201
  elsif TOP_LEVEL.include?(key)
@@ -235,12 +249,24 @@ module HP
235
249
  end
236
250
  end
237
251
 
252
+ def get_acct_catalog_map(account_name)
253
+ hsh = get(account_name)
254
+ provider = hsh[:provider] || 'hp'
255
+ provider = provider.downcase
256
+ catalog = hsh[:catalog] || {}
257
+ options = {}
258
+ options[:catalog] = catalog
259
+ options[:provider] = provider
260
+ return options
261
+ end
262
+
238
263
  def create_options(account_name, zone, avl_zone = nil)
239
264
  hsh = get(account_name)
240
265
  provider = hsh[:provider] || 'hp'
241
266
  provider = provider.downcase
242
267
  creds = hsh[:credentials]
243
268
  regions = hsh[:regions] || {}
269
+ catalog = hsh[:catalog] || {}
244
270
  opts = hsh[:options]
245
271
  opts.delete(:preferred_flavor)
246
272
  opts.delete(:preferred_image)
@@ -261,6 +287,7 @@ module HP
261
287
  options[:hp_avl_zone] = avl_zone
262
288
  options[:connection_options] = opts
263
289
  options[:user_agent] = "HPCloud-UnixCLI/#{HP::Cloud::VERSION}"
290
+ options[:hp_service_type] = zone if zone != nil
264
291
  else
265
292
  options = creds
266
293
  end
@@ -29,10 +29,16 @@ module HP
29
29
  desc 'account:catalog <account_to_catalog> [service]', "Print the service catalog of the specified account."
30
30
  long_desc <<-DESC
31
31
  Print the service catalog of the specified account. Optionally, you may specify a particular service to print such as `Compute`.
32
-
32
+
33
+ You can then configure the catalog for your account with hpcloud account:edit catalog_<service>=<name> so that
34
+ the cli knows how to talk with your particular cloud implementation. For example:
35
+ hpcloud account:edit useast catalog_compute=nova
36
+ See hpcloud help account:edit for more details.
37
+
33
38
  Examples:
34
39
  hpcloud account:catalog useast # Print the service catalog of `useast`:
35
40
  hpcloud account:catalog useast Compute # Print the compute catalog of `useast`:
41
+
36
42
  DESC
37
43
  method_option :debug, :type => :string, :alias => '-x',
38
44
  :desc => 'Debug logging 1,2,3,...'
@@ -53,6 +53,7 @@ Examples:
53
53
  hpcloud account:edit # Edit the default account settings interactively
54
54
  hpcloud account:edit pro auth_uri='https://127.0.0.1/' block_availability_zone='az-2.region-a.geo-1' # Set the account credential authorization URI to `https://127.0.0.1\` and the block availability zone to `az-2.region-a.geo-1`
55
55
  hpcloud account:setup rackspace -p rackspace # Create a Rackspace account for migration
56
+ hpcloud account:edit pro catalog_compute=nova catalog_networking=neutron catalog_block_storage=cinder # will configure your cli to understand that the catalog name for compute on your cloud is called nova
56
57
 
57
58
  Aliases: account:add, account:setup, account:update
58
59
  DESC
@@ -89,7 +89,7 @@ module HP
89
89
  @authcache.write(opts, creds)
90
90
  end
91
91
  if opts[:hp_avl_zone].nil?
92
- opts[:hp_avl_zone] = @authcache.default_zone(opts, service)
92
+ opts[:hp_avl_zone] = @authcache.default_zone(opts, service_type_name(account, service))
93
93
  end
94
94
  opts[:credentials] = creds
95
95
  end
@@ -217,11 +217,16 @@ module HP
217
217
  end
218
218
 
219
219
  def create_options(account_name, zone)
220
- opts = Accounts.new.create_options(account_name, zone, @options[:availability_zone])
220
+ real_zone_name = (zone != nil) ? service_type_name(account_name, zone): zone
221
+ opts = Accounts.new.create_options(account_name, real_zone_name, @options[:availability_zone])
221
222
  opts[:hp_tenant_id] = @options[:tenantid] unless @options[:tenantid].nil?
222
223
  return opts
223
224
  end
224
225
 
226
+ def get_acct_catalog_map(account_name)
227
+ return Accounts.new.get_acct_catalog_map(account_name)
228
+ end
229
+
225
230
  def zones(service)
226
231
  name = get_account(nil)
227
232
  cata = catalog(name, service)
@@ -256,6 +261,27 @@ module HP
256
261
  end
257
262
  end
258
263
 
264
+ # lets identify the real service type name
265
+ # create support for account config to have a section called :service_catalog
266
+ # This section will identify mappings for keys like : object_storage, compute, block_storage, cdn
267
+ # networking, dns, and load_balancer
268
+ # The values can be the real names of the offerings. This enables private cloud implementations to
269
+ # have service catalog names that make more sense for there implementation.
270
+ def service_type_name(account_name, name)
271
+ map_opts = get_acct_catalog_map(account_name)
272
+ case map_opts[:provider]
273
+ when "hp"
274
+ service_name = name
275
+ unless map_opts[:catalog].nil?
276
+ service_catalog_key = name.to_s.downcase.gsub(' ','_').to_sym
277
+ service_name = map_opts[:catalog][service_catalog_key] if map_opts[:catalog].has_key?(service_catalog_key)
278
+ end
279
+ return service_name
280
+ else
281
+ return name
282
+ end
283
+ end
284
+
259
285
  def tenants(account_name = nil)
260
286
  account = get_account(account_name)
261
287
  opts = create_options(account, nil)
@@ -21,7 +21,7 @@
21
21
 
22
22
  module HP
23
23
  module Cloud
24
- VERSION = '2.0.6'
25
- SHA1 = '839edf03a372bf62a59caebcee1908e5018a5d4b'
24
+ VERSION = '2.0.8'
25
+ SHA1 = '7ccf63b42f0eed051d345f36c123b2c8902e0f9e'
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hpcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-06-08 00:00:00.000000000 Z
14
+ date: 2014-06-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor