1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[zerigo] change user to email and add credentials example

This commit is contained in:
geemus 2010-12-15 15:45:19 -08:00
parent 4d739e6054
commit d7927812e6
3 changed files with 39 additions and 37 deletions

View file

@ -5,7 +5,7 @@ require 'fog'
LINODE_API_KEY = '--put-your-key-here--' LINODE_API_KEY = '--put-your-key-here--'
SLICEHOST_PASSWORD = '--put-your-key-here--' SLICEHOST_PASSWORD = '--put-your-key-here--'
ZERIGO_USER = '--put-your-username-here--' ZERIGO_EMAIL = '--put-your-email-here--'
ZERIGO_PASSWORD = '--put-your-password-here--' ZERIGO_PASSWORD = '--put-your-password-here--'
@ -158,16 +158,16 @@ def show_slicehost_dns_usage( password)
end end
# example of how to use Zerigo DNS calls # example of how to use Zerigo DNS calls
def show_zerigo_dns_usage( username, password) def show_zerigo_dns_usage(email, password)
#check if we have a value api key for this cloud #check if we have a value api key for this cloud
if username == '--put-your-username-here--' if email == '--put-your-email-here--'
return false return false
end end
begin begin
#connect to Zerigo #connect to Zerigo
options = { :zerigo_user => username, :zerigo_password => password } options = { :zerigo_email => email, :zerigo_password => password }
cloud = Fog::Zerigo::Compute.new( options) cloud = Fog::Zerigo::Compute.new( options)
#create a domain #create a domain
@ -267,6 +267,6 @@ end
# note, if you have not added your key for a given provider, the related function will do nothing # note, if you have not added your key for a given provider, the related function will do nothing
show_linode_dns_usage( LINODE_API_KEY) show_linode_dns_usage(LINODE_API_KEY)
show_slicehost_dns_usage( SLICEHOST_PASSWORD) show_slicehost_dns_usage(SLICEHOST_PASSWORD)
show_zerigo_dns_usage( ZERIGO_USER, ZERIGO_PASSWORD) show_zerigo_dns_usage(ZERIGO_EMAIL, ZERIGO_PASSWORD)

View file

@ -47,10 +47,10 @@ To run as '#{credential}', add the following to your resource config file: #{con
An alternate file may be used by placing its path in the FOG_RC environment variable An alternate file may be used by placing its path in the FOG_RC environment variable
####################################################### #######################################################
# Fog Resource Config File # Fog Credentials File
# #
# Key-value pairs should look like: # Key-value pairs should look like:
# :aws_access_key_id: 022QF06E7MXBSAMPLE # :aws_access_key_id: 022QF06E7MXBSAMPLE
:#{credential}: :#{credential}:
:aws_access_key_id: :aws_access_key_id:
:aws_secret_access_key: :aws_secret_access_key:
@ -72,8 +72,10 @@ An alternate file may be used by placing its path in the FOG_RC environment vari
:slicehost_password: :slicehost_password:
:terremark_username: :terremark_username:
:terremark_password: :terremark_password:
:zerigo_email:
:zerigo_password:
# #
# End of Fog Resource Config File # End of Fog Credentials File
####################################################### #######################################################
YML YML

View file

@ -2,7 +2,7 @@ module Fog
module Zerigo module Zerigo
class Compute < Fog::Service class Compute < Fog::Service
requires :zerigo_user, :zerigo_password, &inject_parameter_specs requires :zerigo_email, :zerigo_password, &inject_parameter_specs
recognizes :timeout, :persistent, &inject_parameter_specs recognizes :timeout, :persistent, &inject_parameter_specs
# model_path 'fog/zerigo/models/compute' # model_path 'fog/zerigo/models/compute'
@ -40,9 +40,9 @@ module Fog
end end
def initialize(options={}) def initialize(options={})
@zerigo_user = options[:zerigo_user] @zerigo_email = options[:zerigo_email]
@zerigo_password = options[:zerigo_password] @zerigo_password = options[:zerigo_password]
@data = self.class.data[@zerigo_user] @data = self.class.data[@zerigo_email]
@data = self.class.data[@zerigo_password] @data = self.class.data[@zerigo_password]
end end
@ -51,8 +51,8 @@ module Fog
class Real class Real
def initialize(options={}) def initialize(options={})
@zerigo_user = options[:zerigo_user] @zerigo_email = options[:zerigo_email]
@zerigo_password = options[:zerigo_password] @zerigo_password = options[:zerigo_password]
@host = options[:host] || "ns.zerigo.com" @host = options[:host] || "ns.zerigo.com"
@port = options[:port] || 80 @port = options[:port] || 80
@scheme = options[:scheme] || 'http' @scheme = options[:scheme] || 'http'
@ -65,7 +65,7 @@ module Fog
def request(params) def request(params)
params[:headers] ||= {} params[:headers] ||= {}
key= "#{@zerigo_user}:#{@zerigo_password}" key= "#{@zerigo_email}:#{@zerigo_password}"
params[:headers].merge!({ params[:headers].merge!({
'Authorization' => "Basic #{Base64.encode64(key).delete("\r\n")}" 'Authorization' => "Basic #{Base64.encode64(key).delete("\r\n")}"
}) })