Method: HP::Cloud::Accounts#create_options

Defined in:
lib/hpcloud/accounts.rb

#create_options(account_name, zone, avl_zone = nil) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/hpcloud/accounts.rb', line 263

def create_options(, zone, avl_zone = nil)
  hsh = get()
  provider = hsh[:provider] || 'hp'
  provider = provider.downcase
  creds = hsh[:credentials]
  regions = hsh[:regions] || {}
  catalog = hsh[:catalog] || {}
  opts = hsh[:options]
  opts.delete(:preferred_flavor)
  opts.delete(:preferred_image)
  opts.delete(:preferred_win_image)
  opts.delete(:checker_url)
  opts.delete(:checker_deferment)
  unless zone.nil?
    avl_zone = avl_zone || regions[zone.to_s.downcase.to_sym]
  end

  options = {}
  if provider == 'hp'
    options[:hp_access_key] = creds[:account_id] || creds[:hp_access_key] || creds[:hp_account_id]
    options[:hp_secret_key] = creds[:secret_key] || creds[:hp_secret_key]
    options[:hp_use_upass_auth_style] = true if creds[:userpass] == true
    options[:hp_auth_uri] = creds[:auth_uri] || creds[:hp_auth_uri]
    options[:hp_tenant_id ] = creds[:tenant_id] || creds[:hp_tenant_id]
    options[:hp_avl_zone] = avl_zone
    options[:connection_options] = opts
    options[:user_agent] = "HPCloud-UnixCLI/#{HP::Cloud::VERSION}"
    options[:hp_service_type] = zone if zone != nil
  else
    options = creds
  end
  options[:provider] = provider

  return options
end