Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #126 from guangyang/release-0.6.1
Browse files Browse the repository at this point in the history
Release 0.6.1
  • Loading branch information
guangyang committed Feb 18, 2014
2 parents 475176b + 490d909 commit 2b5abea
Show file tree
Hide file tree
Showing 18 changed files with 317 additions and 331 deletions.
22 changes: 0 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,3 @@ script:
- rake test:unit
- if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ] ; then rake test:integration ; fi

env:
global:
- secure: ! 'EMSKuCl/BixCkv7eLIVYj3UbCg0AVUj4h87k11XFwNgRfj1f884lzgNAbIKX
IknDibQFz7OwMApMK12SmbmzXGKV1WlGevDL1Jbv1pYxfvjjRJYy1yaXJTBu
Y0tyvX2psZLFsMT1k1/NehzDuRYnzFGhDKdVgUCh+YTNa8KY3Kg='
- secure: ! 'UzKA8lMUIUuNqHplayxTM9qFD5e70B5AdRXa1iSHRgOrzBoRuWHr2OrI9cUC
XQ8tncOhU8mMXLL3xKzyOxTE+TX2rEE6c5tHMM0099+yCQBjwRgcZCIMlcDy
T+hCPOPZngFWM8z38S3wH39bOM3ddGO05I8jCN1HqXRcR92BS0I='
- secure: ! 'nWqLZqxm8u7bxU1gsnzEH9NT8NNnTwFNyDTAZRcHTUcuiR5jVI3+YH1+cFQ3
e/J1JBwqPO0T/IaR59ujGWpfd2UFSUvSa95cKlDg1BgDzQQ3yYS3gNssqoQW
Zbfabil9akFl2CZWliR1maQKkjDaEeUI6MLeBrj9i8giB2gxLg0='
- secure: ! 'BL/xe3bbmKhcK9gXI6dOhM7XPh/5YhiaEanEWGvgUQfcHMrmqiDHnjbeF+8M
+SwmmseAD7EzT/Q3gjJh3PcB35IIUsX/RyFuNNghuuiHg9G+uiRG9YQi9AFT
gIBIuWS3/vDYs05G1fib1rfFBRq66kJo6lIO8XFdSs+9jcLvPiI='
5 changes: 5 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2014.02.18 - version 0.6.1
* Fixed http redirection error.
* Add a new role to existing deployment
* Add support for including VMs in availability sets

2013.12.02 - version 0.6.0
* Add the following service management API
* Virtual Machine
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ options = {
:vm_size => 'Small', #valid choices are (ExtraSmall, Small, Medium, Large, ExtraLarge, A6, A7)
:affinity_group_name => 'affinity1',
:virtual_network_name => 'xplattestvnet',
:subnet_name => 'subnet1'
:subnet_name => 'subnet1',
:availability_set_name => 'availabiltyset1'
}
virtual_machine_service.create_virtual_machine(params,options,add_role=false)
# Here add_role is used as a flag to create multiple roles under the same cloud service. This parameter is false
Expand Down
13 changes: 7 additions & 6 deletions azure.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 1.9.3'

s.add_runtime_dependency("nokogiri", "~> 1.5")
s.add_runtime_dependency('nokogiri', "~> 1.5")
s.add_runtime_dependency("mime-types", "~> 1.0")
s.add_runtime_dependency "json"
s.add_runtime_dependency "uuid"
s.add_runtime_dependency('json', '~> 1.8')
s.add_runtime_dependency('uuid', '~> 2.0')
s.add_runtime_dependency('systemu', '~> 2.6')

s.add_development_dependency("rake")
s.add_development_dependency("rake", '~> 10.0')
s.add_development_dependency("minitest", "~> 3.0")
s.add_development_dependency("mocha")
s.add_development_dependency("turn")
s.add_development_dependency('mocha', '~> 1.0')
s.add_development_dependency('turn', '~> 0.9')
end
129 changes: 76 additions & 53 deletions lib/azure/base_management/management_http_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#--------------------------------------------------------------------------
require "azure/core/http/http_response"
require "azure/core/http/http_request"
require 'azure/core/http/http_response'
require 'azure/core/http/http_request'
include Azure::Core::Http

# Represents an HTTP request that can perform synchronous queries to
# an HTTP server, returning a HttpResponse
module Azure
module BaseManagement
class ManagementHttpRequest < HttpRequest

attr_accessor :uri,:warn,:key,:cert
attr_accessor :uri, :warn, :key, :cert

# Public: Creates the ManagementHttpRequest
#
Expand All @@ -31,14 +30,14 @@ class ManagementHttpRequest < HttpRequest
# body - IO or String. The request body (optional)
# key - String. The request key
# cert - String. The request certificate
def initialize(method, path, body=nil)
def initialize(method, path, body = nil)
super
@warn = false
content_length = body ? body.bytesize.to_s : "0"
content_length = body ? body.bytesize.to_s : '0'
@headers = {
"x-ms-version" => "2013-06-01",
"Content-Type"=> 'application/xml',
"Content-Length" => content_length
'x-ms-version' => '2013-06-01',
'Content-Type' => 'application/xml',
'Content-Length' => content_length
}
@uri = URI.parse(Azure.config.management_endpoint + Azure.config.subscription_id + path)
@key = Azure.config.http_private_key
Expand All @@ -51,32 +50,10 @@ def initialize(method, path, body=nil)
def call
request = http_request_class.new(uri.request_uri, headers)
request.body = body if body

http = nil
if ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY']
if ENV['HTTP_PROXY']
proxy_uri = URI::parse(ENV['HTTP_PROXY'])
else
proxy_uri = URI::parse(ENV['HTTPS_PROXY'])
end

http = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new(uri.host, uri.port)
else
http = Net::HTTP.new(uri.host, uri.port)
end

if uri.scheme.downcase == 'https'
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.cert = cert
http.key = key
end
#http.set_debug_output($stdout)
response = HttpResponse.new(http.request(request))
response.uri = uri

wait_for_completion(response)
Nokogiri::XML response.body
http = http_setup
# http.set_debug_output($stdout)
response = wait_for_completion(HttpResponse.new(http.request(request)))
Nokogiri::XML response.body unless response.nil?
end

# Public: Wait for HTTP request completion.
Expand All @@ -91,12 +68,14 @@ def wait_for_completion(response)
if ret_val.at_css('Error Code') && ret_val.at_css('Error Code').content == 'AuthenticationFailed'
Loggerx.error_with_exit ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
end
if (response.status_code.to_i == 200 or response.status_code.to_i == 201)
ret_val
if response.status_code.to_i == 200 || response.status_code.to_i == 201
return response
elsif redirected? response
rebuild_request response
elsif response.status_code.to_i > 201 && response.status_code.to_i <= 299
ret_val = check_completion(response.headers['x-ms-request-id'])
check_completion(response.headers['x-ms-request-id'])
elsif warn && !response.success?
#Loggerx.warn ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
# Loggerx.warn ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
elsif response.body
if ret_val.at_css('Error Code') && ret_val.at_css('Error Message')
Loggerx.error_with_exit ret_val.at_css('Error Code').content + ' : ' + ret_val.at_css('Error Message').content
Expand All @@ -106,7 +85,6 @@ def wait_for_completion(response)
else
Loggerx.exception_message "http error: #{response.status_code}"
end
ret_val
end

# Public: Gets the status of the specified operation and determines whether
Expand All @@ -120,29 +98,74 @@ def wait_for_completion(response)
#
# Print Error or Success of Operation.
def check_completion(request_id)
request_path= "/operations/#{request_id}"
request_path = "/#{Azure.config.subscription_id}/operations/#{request_id}"
http = http_setup
headers['Content-Length'] = '0'
@method = :get
done = false
while not done
print '# '
request= ManagementHttpRequest.new(:get, request_path)
response = request.call
status = xml_content(response, 'Operation Status')
status_code = xml_content(response, 'Operation HttpStatusCode')
done = status != 'InProgress'
request = http_request_class.new(request_path, headers)
response = HttpResponse.new(http.request(request))
ret_val = Nokogiri::XML response.body
status = xml_content(ret_val, 'Operation Status')
status_code = response.status_code.to_i
if status != 'InProgress'
done = true
end
if redirected? response
host_uri = URI.parse(response.headers['location'])
http = http_setup(host_uri)
done = false
end
if done
if status.downcase != "succeeded"
error_code = xml_content(response, 'Operation Error Code')
error_msg = xml_content(response, 'Operation Error Message')
if status.downcase != 'succeeded'
error_code = xml_content(ret_val, 'Operation Error Code')
error_msg = xml_content(ret_val, 'Operation Error Message')
Loggerx.exception_message "#{error_code}: #{error_msg}"
else
Loggerx.success " #{status.downcase} (#{status_code})"
Loggerx.success "#{status.downcase} (#{status_code})"
end
puts ''
return
else
sleep(1)
sleep(5)
end
end
response
end

def rebuild_request(response)
host_uri = URI.parse(response.headers['location'])
request = http_request_class.new(host_uri.request_uri, headers)
request.body = body if body
http = http_setup(host_uri)
wait_for_completion(HttpResponse.new(http.request(request)))
end

def redirected?(response)
(response.status_code.to_i == 307)
end

def http_setup(host_uri = nil)
@uri = host_uri if host_uri
http = nil
if ENV['HTTP_PROXY'] || ENV['HTTPS_PROXY']
if ENV['HTTP_PROXY']
proxy_uri = URI.parse(ENV['HTTP_PROXY'])
else
proxy_uri = URI.parse(ENV['HTTPS_PROXY'])
end
http = Net::HTTP::Proxy(proxy_uri.host, proxy_uri.port).new(uri.host, uri.port)
else
http = Net::HTTP.new(uri.host, uri.port)
end

if uri.scheme.downcase == 'https'
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.cert = cert
http.key = key
end
http
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/azure/blob/blob_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def create_page_blob(container, blob, length, options={})
# ==== Options
#
# Accepted key/value pairs in options parameter are:
# * +:if_sequence_number_lte+ - If the blob's sequence number is less than or equal to the specified value, the request proceeds; otherwise it fails with the SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
# * +:if_sequence_number_le+ - If the blob's sequence number is less than or equal to the specified value, the request proceeds; otherwise it fails with the SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
# * +:if_sequence_number_lt+ - If the blob's sequence number is less than the specified value, the request proceeds; otherwise it fails with SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
# * +:if_sequence_number_eq+ - If the blob's sequence number is equal to the specified value, the request proceeds; otherwise it fails with SequenceNumberConditionNotMet error (HTTP status code 412 - Precondition Failed).
# * +:if_modified_since+ - A DateTime value. Specify this conditional header to write the page only if the blob has been modified since the specified date/time. If the blob has not been modified, the Blob service returns status code 412 (Precondition Failed).
Expand All @@ -486,7 +486,7 @@ def create_blob_pages(container, blob, start_range, end_range, content, options=

# set optional headers
unless options.empty?
headers["x-ms-if-sequence-number-lte"] = options[:if_sequence_number_lte] if options[:if_sequence_number_lte]
headers["x-ms-if-sequence-number-le"] = options[:if_sequence_number_le] if options[:if_sequence_number_le]
headers["x-ms-if-sequence-number-lt"] = options[:if_sequence_number_lt] if options[:if_sequence_number_lt]
headers["x-ms-if-sequence-number-eq"] = options[:if_sequence_number_eq] if options[:if_sequence_number_eq]
headers["If-Modified-Since"] = options[:if_modified_since] if options[:if_modified_since]
Expand Down
2 changes: 1 addition & 1 deletion lib/azure/core/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def sql_database_management_endpoint
def sql_database_authentication_mode
sdam = @sql_database_authentication_mode || :sql_server
if [:sql_server, :management_certificate].include? sdam.to_sym
@sql_database_authentication_mode.to_sym
sdam.to_sym
else
:sql_server
end
Expand Down
2 changes: 1 addition & 1 deletion lib/azure/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Azure
class Version
MAJOR = 0 unless defined? MAJOR
MINOR = 6 unless defined? MINOR
UPDATE = 0 unless defined? UPDATE
UPDATE = 1 unless defined? UPDATE
PRE = nil unless defined? PRE

class << self
Expand Down
Loading

0 comments on commit 2b5abea

Please sign in to comment.