Module: AzureHelper

Defined in:
lib/azure_helper.rb

Constant Summary collapse

RS_LINUX_ACCOUNTS =
%w(
  rightscalewestus
  rightscaleeastus
  rightscaleeastasia
  rightscalesoutheastasia
  rightscalenortheurope
  rightscalewesteurope
)
RS_WINDOWS_ACCOUNTS =
%w(
  rightscalewestuswin
  rightscaleeastuswin
  rightscaleeastasiawin
  rightscaleseasiawin
  rightscalenortheuropewin
  rightscalewesteuropewin
)
AZURE_LINUX_LOCATIONS =
{
  'rightscalewesteurope' => 'West Europe',
  'rightscalesoutheastasia' => 'Southeast Asia',
  'rightscaleeastasia' => 'East Asia',
  'rightscalenortheurope' => 'North Europe',
  'rightscalewestus' => 'West US',
  'rightscaleeastus' => 'East US'
}

Instance Method Summary collapse

Instance Method Details

#api_dump(api, method_name, *args) ⇒ Object

}



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/azure_helper.rb', line 34

def api_dump(api, method_name, *args)
  result = api.__send__(method_name, *args)
ensure
  puts "--- #{method_name} ---"  
  if api.request
    puts "verb:         #{api.request.verb}"
    puts "path:         #{api.request.path.inspect}"
    puts "req headers:  #{api.request.headers.inspect}"
    puts "req body:     #{api.request.body.inspect}"
    puts " "
    if api.response
      puts "resp code:    #{api.response.code.inspect}"
      puts "resp headers: #{api.response.headers.inspect}"
      puts "resp body:    #{api.response.body.inspect}"
      puts " "
      pp result
    end
    puts "==========================================================================="
  end
end

#lookup_password(account) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/azure_helper.rb', line 55

def lookup_password()
  credsfile = "~/.azurecreds.yml"
  creds_msg = <<-EOF
  Please set up a #{credsfile} file in the following format:
  <service account name1>: <shared key2>
  <service account name1>: <shared key2>
  EOF
  begin
    creds = YAML.load_file(File.expand_path(credsfile))
  rescue
    puts creds_msg
    exit 1
  end
  password = creds[]
  unless password
    puts "Can not find creds for account #{} in file"
    puts creds_msg
    exit 1
  end
  password
end

#parse_url(url) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/azure_helper.rb', line 77

def parse_url(url)
  uri = URI.parse(url)
  path = uri.path.reverse.chomp("/").reverse
  (container, blob) = path.split("/",2)
   = uri.host.split(".").first
#    puts "ACCOUNT: #{account}"
#    puts "CONTAINER: #{container}"
#    puts "BLOB NAME: #{blob}"

  password = lookup_password()
  endpoint = "https://#{}.blob.core.windows.net"
  return [,password,endpoint,container,blob]
end