# File 'lib/fog/hp/cdn.rb', line 67definitialize(options={})# deprecate hp_account_id
ifoptions[:hp_account_id]Fog::Logger.deprecation(":hp_account_id is deprecated, please use :hp_access_key instead.")options[:hp_access_key]=options.delete(:hp_account_id)end@hp_access_key=options[:hp_access_key]unless@hp_access_keyraiseArgumentError.new("Missing required arguments: hp_access_key. :hp_account_id is deprecated, please use :hp_access_key instead.")end@hp_secret_key=options[:hp_secret_key]@connection_options=options[:connection_options]||{}### Set an option to use the style of authentication desired; :v1 or :v2 (default)
### A symbol is required, we should ensure that the value is loaded as a symbol
auth_version=options[:hp_auth_version]||:v2auth_version=auth_version.to_s.downcase.to_sym### Pass the service name for object storage to the authentication call
options[:hp_service_type]||="CDN"@hp_tenant_id=options[:hp_tenant_id]### Make the authentication call
if(auth_version==:v2)# Call the control services authentication
credentials=Fog::HP.authenticate_v2(options,@connection_options)### When using the v2 CS authentication, the CDN Mgmt comes from the service catalog
@hp_cdn_uri=credentials[:endpoint_url]cdn_mgmt_url=@hp_cdn_uri@credentials=credentialselse# Call the legacy v1.0/v1.1 authentication
credentials=Fog::HP.authenticate_v1(options,@connection_options)# In case of legacy authentication systems, the user can pass the CDN Mgmt Uri
@hp_cdn_uri=options[:hp_cdn_uri]||"https://region-a.geo-1.cdnmgmt.hpcloudsvc.com/v1.0"# In case of legacy authentication systems, the :cdn_endpoint_url will carry the cdn storage url
cdn_mgmt_url="#{@hp_cdn_uri}#{URI.parse(credentials[:cdn_endpoint_url]).path}"end@auth_token=credentials[:auth_token]@enabled=false@persistent=options[:persistent]||falseifcdn_mgmt_urluri=URI.parse(cdn_mgmt_url)@host=uri.host@path=uri.path.chomp("/")@port=uri.port@scheme=uri.scheme@connection=Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}",@persistent,@connection_options)@enabled=trueendend