Skip to content
Browse files

Merge pull request #877 from fog/loosen_multi_json_version

Fixed #875: Loosen multi_json version.
  • Loading branch information...
2 parents b98f3a1 + dcefc2d commit edf1c60c5d379dec1a6e048450eefa667059f953 @geemus geemus committed
Showing with 170 additions and 190 deletions.
  1. +3 −3 Rakefile
  2. +1 −3 bin/fog
  3. +1 −1 fog.gemspec
  4. +0 −1 lib/fog/aws/beanstalk.rb
  5. +0 −1 lib/fog/aws/cloud_formation.rb
  6. +1 −3 lib/fog/aws/dynamodb.rb
  7. +0 −1 lib/fog/aws/iam.rb
  8. +1 −2 lib/fog/aws/models/compute/server.rb
  9. +1 −1 lib/fog/aws/requests/dynamodb/batch_get_item.rb
  10. +1 −1 lib/fog/aws/requests/dynamodb/batch_put_item.rb
  11. +1 −1 lib/fog/aws/requests/dynamodb/create_table.rb
  12. +1 −1 lib/fog/aws/requests/dynamodb/delete_item.rb
  13. +1 −1 lib/fog/aws/requests/dynamodb/delete_table.rb
  14. +1 −1 lib/fog/aws/requests/dynamodb/describe_table.rb
  15. +1 −1 lib/fog/aws/requests/dynamodb/get_item.rb
  16. +1 −1 lib/fog/aws/requests/dynamodb/list_tables.rb
  17. +1 −1 lib/fog/aws/requests/dynamodb/put_item.rb
  18. +1 −1 lib/fog/aws/requests/dynamodb/query.rb
  19. +1 −1 lib/fog/aws/requests/dynamodb/scan.rb
  20. +1 −1 lib/fog/aws/requests/dynamodb/update_item.rb
  21. +1 −1 lib/fog/aws/requests/dynamodb/update_table.rb
  22. +1 −1 lib/fog/aws/requests/iam/put_group_policy.rb
  23. +1 −1 lib/fog/aws/requests/iam/put_user_policy.rb
  24. +1 −1 lib/fog/aws/requests/storage/get_bucket_policy.rb
  25. +1 −1 lib/fog/aws/requests/storage/post_object_hidden_fields.rb
  26. +1 −1 lib/fog/aws/requests/storage/put_bucket_policy.rb
  27. +1 −1 lib/fog/aws/requests/sts/get_federation_token.rb
  28. +0 −1 lib/fog/aws/sns.rb
  29. +0 −1 lib/fog/aws/storage.rb
  30. +0 −1 lib/fog/aws/sts.rb
  31. +1 −2 lib/fog/bluebox/compute.rb
  32. +1 −1 lib/fog/bluebox/models/compute/server.rb
  33. +4 −5 lib/fog/brightbox/compute.rb
  34. +1 −1 lib/fog/brightbox/requests/compute/resize_server.rb
  35. +1 −3 lib/fog/clodo/compute.rb
  36. +1 −1 lib/fog/clodo/models/compute/server.rb
  37. +1 −1 lib/fog/clodo/requests/compute/create_server.rb
  38. +1 −1 lib/fog/clodo/requests/compute/delete_ip_address.rb
  39. +1 −1 lib/fog/clodo/requests/compute/move_ip_address.rb
  40. +1 −1 lib/fog/clodo/requests/compute/server_action.rb
  41. +3 −4 lib/fog/cloudstack/compute.rb
  42. +1 −2 lib/fog/core/collection.rb
  43. +26 −0 lib/fog/core/json.rb
  44. +1 −2 lib/fog/core/model.rb
  45. +1 −3 lib/fog/dnsimple/dns.rb
  46. +1 −1 lib/fog/dnsimple/requests/dns/create_domain.rb
  47. +1 −1 lib/fog/dnsimple/requests/dns/create_record.rb
  48. +1 −1 lib/fog/dnsimple/requests/dns/update_record.rb
  49. +1 −2 lib/fog/dnsmadeeasy/dns.rb
  50. +1 −1 lib/fog/dnsmadeeasy/requests/dns/create_record.rb
  51. +1 −1 lib/fog/dnsmadeeasy/requests/dns/create_secondary.rb
  52. +1 −1 lib/fog/dnsmadeeasy/requests/dns/update_record.rb
  53. +1 −1 lib/fog/dnsmadeeasy/requests/dns/update_secondary.rb
  54. +1 −3 lib/fog/dynect/dns.rb
  55. +1 −1 lib/fog/dynect/requests/dns/post_record.rb
  56. +1 −1 lib/fog/dynect/requests/dns/post_session.rb
  57. +1 −1 lib/fog/dynect/requests/dns/post_zone.rb
  58. +1 −1 lib/fog/dynect/requests/dns/put_zone.rb
  59. +1 −2 lib/fog/glesys/compute.rb
  60. +1 −2 lib/fog/go_grid/compute.rb
  61. +2 −2 lib/fog/go_grid/models/compute/server.rb
  62. +3 −3 lib/fog/hp.rb
  63. +1 −2 lib/fog/hp/cdn.rb
  64. +1 −2 lib/fog/hp/compute.rb
  65. +2 −2 lib/fog/hp/models/compute/server.rb
  66. +1 −1 lib/fog/hp/requests/compute/create_key_pair.rb
  67. +1 −1 lib/fog/hp/requests/compute/create_security_group.rb
  68. +1 −1 lib/fog/hp/requests/compute/create_security_group_rule.rb
  69. +1 −1 lib/fog/hp/requests/compute/create_server.rb
  70. +1 −1 lib/fog/hp/requests/compute/server_action.rb
  71. +1 −1 lib/fog/hp/requests/compute/update_server.rb
  72. +1 −2 lib/fog/hp/storage.rb
  73. +1 −2 lib/fog/ibm.rb
  74. +2 −3 lib/fog/joyent/compute.rb
  75. +1 −2 lib/fog/libvirt/models/compute/server.rb
  76. +1 −2 lib/fog/linode/compute.rb
  77. +1 −2 lib/fog/linode/dns.rb
  78. +1 −1 lib/fog/linode/requests/compute/linode_disk_createfromstackscript.rb
  79. +1 −5 lib/fog/ninefold/compute.rb
  80. +3 −3 lib/fog/openstack.rb
  81. +1 −3 lib/fog/openstack/compute.rb
  82. +2 −2 lib/fog/openstack/models/compute/server.rb
  83. +1 −1 lib/fog/openstack/requests/compute/create_server.rb
  84. +1 −1 lib/fog/openstack/requests/compute/server_action.rb
  85. +1 −1 lib/fog/openstack/requests/compute/set_metadata.rb
  86. +1 −1 lib/fog/openstack/requests/compute/update_meta.rb
  87. +1 −1 lib/fog/openstack/requests/compute/update_metadata.rb
  88. +1 −1 lib/fog/openstack/requests/compute/update_server.rb
  89. +1 −1 lib/fog/rackspace.rb
  90. +1 −2 lib/fog/rackspace/cdn.rb
  91. +1 −3 lib/fog/rackspace/compute.rb
  92. +1 −2 lib/fog/rackspace/dns.rb
  93. +1 −2 lib/fog/rackspace/load_balancers.rb
  94. +2 −2 lib/fog/rackspace/models/compute/server.rb
  95. +1 −1 lib/fog/rackspace/requests/compute/create_image.rb
  96. +1 −1 lib/fog/rackspace/requests/compute/create_server.rb
  97. +1 −1 lib/fog/rackspace/requests/compute/server_action.rb
  98. +1 −1 lib/fog/rackspace/requests/compute/update_server.rb
  99. +1 −1 lib/fog/rackspace/requests/dns/add_records.rb
  100. +1 −1 lib/fog/rackspace/requests/dns/create_domains.rb
  101. +1 −1 lib/fog/rackspace/requests/dns/modify_domain.rb
  102. +1 −1 lib/fog/rackspace/requests/dns/modify_record.rb
  103. +1 −1 lib/fog/rackspace/requests/load_balancers/create_access_rule.rb
  104. +1 −1 lib/fog/rackspace/requests/load_balancers/create_load_balancer.rb
  105. +1 −1 lib/fog/rackspace/requests/load_balancers/create_node.rb
  106. +1 −1 lib/fog/rackspace/requests/load_balancers/create_virtual_ip.rb
  107. +1 −1 lib/fog/rackspace/requests/load_balancers/set_connection_logging.rb
  108. +1 −1 lib/fog/rackspace/requests/load_balancers/set_connection_throttling.rb
  109. +1 −1 lib/fog/rackspace/requests/load_balancers/set_error_page.rb
  110. +1 −1 lib/fog/rackspace/requests/load_balancers/set_monitor.rb
  111. +1 −1 lib/fog/rackspace/requests/load_balancers/set_session_persistence.rb
  112. +1 −1 lib/fog/rackspace/requests/load_balancers/update_load_balancer.rb
  113. +1 −1 lib/fog/rackspace/requests/load_balancers/update_node.rb
  114. +1 −2 lib/fog/rackspace/storage.rb
  115. +1 −1 lib/fog/slicehost/models/compute/server.rb
  116. +1 −2 lib/fog/storm_on_demand/compute.rb
  117. +1 −1 lib/fog/storm_on_demand/requests/compute/add_balancer_node.rb
  118. +1 −1 lib/fog/storm_on_demand/requests/compute/clone_server.rb
  119. +1 −1 lib/fog/storm_on_demand/requests/compute/create_server.rb
  120. +1 −1 lib/fog/storm_on_demand/requests/compute/delete_server.rb
  121. +1 −1 lib/fog/storm_on_demand/requests/compute/get_server.rb
  122. +1 −1 lib/fog/storm_on_demand/requests/compute/get_stats.rb
  123. +1 −1 lib/fog/storm_on_demand/requests/compute/list_balancers.rb
  124. +1 −1 lib/fog/storm_on_demand/requests/compute/list_configs.rb
  125. +1 −1 lib/fog/storm_on_demand/requests/compute/list_images.rb
  126. +1 −1 lib/fog/storm_on_demand/requests/compute/list_private_ips.rb
  127. +1 −1 lib/fog/storm_on_demand/requests/compute/list_servers.rb
  128. +1 −1 lib/fog/storm_on_demand/requests/compute/list_templates.rb
  129. +1 −1 lib/fog/storm_on_demand/requests/compute/reboot_server.rb
  130. +1 −1 lib/fog/storm_on_demand/requests/compute/remove_balancer_node.rb
  131. +1 −1 lib/fog/storm_on_demand/requests/compute/resize_server.rb
  132. +2 −2 lib/fog/virtual_box/models/compute/server.rb
  133. +2 −2 tests/aws/requests/sns/subscription_tests.rb
View
6 Rakefile
@@ -189,11 +189,11 @@ task :changelog do
changelog << ''
require 'multi_json'
- github_repo_data = MultiJson.load(Excon.get('http://github.com/api/v2/json/repos/show/fog/fog').body)
+ github_repo_data = Fog::JSON.decode(Excon.get('http://github.com/api/v2/json/repos/show/fog/fog').body)
data = github_repo_data['repository'].reject {|key, value| !['forks', 'open_issues', 'watchers'].include?(key)}
- github_collaborator_data = MultiJson.load(Excon.get('http://github.com/api/v2/json/repos/show/fog/fog/collaborators').body)
+ github_collaborator_data = Fog::JSON.decode(Excon.get('http://github.com/api/v2/json/repos/show/fog/fog/collaborators').body)
data['collaborators'] = github_collaborator_data['collaborators'].length
- rubygems_data = MultiJson.load(Excon.get('https://rubygems.org/api/v1/gems/fog.json').body)
+ rubygems_data = Fog::JSON.decode(Excon.get('https://rubygems.org/api/v1/gems/fog.json').body)
data['downloads'] = rubygems_data['downloads']
stats = []
for key in data.keys.sort
View
4 bin/fog
@@ -23,10 +23,8 @@ end
if ARGV.length > 1
- require 'multi_json'
-
result = instance_eval(ARGV[1..-1].join(' '))
- puts(MultiJson.dump(result))
+ puts(Fog::JSON.encode(result))
else
View
2 fog.gemspec
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
s.add_dependency('builder')
s.add_dependency('excon', '~>0.13.0')
s.add_dependency('formatador', '~>0.2.0')
- s.add_dependency('multi_json', '~>1.3')
+ s.add_dependency('multi_json', '~>1.0')
s.add_dependency('mime-types')
s.add_dependency('net-scp', '~>1.0.4')
s.add_dependency('net-ssh', '>=2.1.3')
View
1 lib/fog/aws/beanstalk.rb
@@ -66,7 +66,6 @@ class Real
def initialize(options={})
require 'fog/core/parser'
- require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
View
1 lib/fog/aws/cloud_formation.rb
@@ -46,7 +46,6 @@ class Real
# * CloudFormation object with connection to AWS.
def initialize(options={})
require 'fog/core/parser'
- require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
View
4 lib/fog/aws/dynamodb.rb
@@ -70,8 +70,6 @@ class Real
# ==== Returns
# * DynamoDB object with connection to aws
def initialize(options={})
- require 'multi_json'
-
if options[:aws_session_token]
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@@ -126,7 +124,7 @@ def request(params)
})
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
View
1 lib/fog/aws/iam.rb
@@ -123,7 +123,6 @@ class Real
# * IAM object with connection to AWS.
def initialize(options={})
require 'fog/core/parser'
- require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
View
3 lib/fog/aws/models/compute/server.rb
@@ -192,13 +192,12 @@ def save
def setup(credentials = {})
requires :public_ip_address, :username
- require 'multi_json'
require 'net/ssh'
commands = [
%{mkdir .ssh},
%{passwd -l #{username}},
- %{echo "#{MultiJson.dump(Fog::JSON.sanitize(attributes))}" >> ~/attributes.json}
+ %{echo "#{Fog::JSON.encode(Fog::JSON.sanitize(attributes))}" >> ~/attributes.json}
]
if public_key
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
View
2 lib/fog/aws/requests/dynamodb/batch_get_item.rb
@@ -31,7 +31,7 @@ def batch_get_item(request_items)
}
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.BatchGetItem'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/batch_put_item.rb
@@ -19,7 +19,7 @@ def batch_put_item(request_items)
}
request(
- :body => MultiJson.encode(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.BatchWriteItem'}
)
end
View
2 lib/fog/aws/requests/dynamodb/create_table.rb
@@ -43,7 +43,7 @@ def create_table(table_name, key_schema, provisioned_throughput)
}
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.CreateTable'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/delete_item.rb
@@ -33,7 +33,7 @@ def delete_item(table_name, key, options = {})
}.merge(options)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.DeleteItem'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/delete_table.rb
@@ -30,7 +30,7 @@ def delete_table(table_name)
}
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.DeleteTable'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/describe_table.rb
@@ -32,7 +32,7 @@ def describe_table(table_name)
}
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.DescribeTable'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/get_item.rb
@@ -31,7 +31,7 @@ def get_item(table_name, key, options = {})
}.merge(options)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.GetItem'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/list_tables.rb
@@ -17,7 +17,7 @@ class Real
# * 'TableNames'<~Array> - table names
def list_tables(options = {})
request(
- :body => MultiJson.dump(options),
+ :body => Fog::JSON.encode(options),
:headers => {'x-amz-target' => 'DynamoDB_20111205.ListTables'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/put_item.rb
@@ -30,7 +30,7 @@ def put_item(table_name, item, options = {})
}.merge(options)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.PutItem'}
)
end
View
2 lib/fog/aws/requests/dynamodb/query.rb
@@ -33,7 +33,7 @@ def query(table_name, hash_key, options = {})
}.merge(options)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.Query'}
)
end
View
2 lib/fog/aws/requests/dynamodb/scan.rb
@@ -33,7 +33,7 @@ def scan(table_name, options = {})
}.merge(options)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.Scan'},
:idempotent => true
)
View
2 lib/fog/aws/requests/dynamodb/update_item.rb
@@ -38,7 +38,7 @@ def update_item(table_name, key, attribute_updates, options = {})
}.merge(options)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.UpdateItem'}
)
end
View
2 lib/fog/aws/requests/dynamodb/update_table.rb
@@ -34,7 +34,7 @@ def update_table(table_name, provisioned_throughput)
}
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:headers => {'x-amz-target' => 'DynamoDB_20111205.UpdateTable'},
:idempotent => true
)
View
2 lib/fog/aws/requests/iam/put_group_policy.rb
@@ -25,7 +25,7 @@ def put_group_policy(group_name, policy_name, policy_document)
'Action' => 'PutGroupPolicy',
'GroupName' => group_name,
'PolicyName' => policy_name,
- 'PolicyDocument' => MultiJson.dump(policy_document),
+ 'PolicyDocument' => Fog::JSON.encode(policy_document),
:parser => Fog::Parsers::AWS::IAM::Basic.new
)
end
View
2 lib/fog/aws/requests/iam/put_user_policy.rb
@@ -24,7 +24,7 @@ def put_user_policy(user_name, policy_name, policy_document)
request(
'Action' => 'PutUserPolicy',
'PolicyName' => policy_name,
- 'PolicyDocument' => MultiJson.dump(policy_document),
+ 'PolicyDocument' => Fog::JSON.encode(policy_document),
'UserName' => user_name,
:parser => Fog::Parsers::AWS::IAM::Basic.new
)
View
2 lib/fog/aws/requests/storage/get_bucket_policy.rb
@@ -27,7 +27,7 @@ def get_bucket_policy(bucket_name)
:method => 'GET',
:query => {'policy' => nil}
})
- response.body = MultiJson.load(response.body) unless response.body.nil?
+ response.body = Fog::JSON.decode(response.body) unless response.body.nil?
end
end
View
2 lib/fog/aws/requests/storage/post_object_hidden_fields.rb
@@ -27,7 +27,7 @@ class Real
def post_object_hidden_fields(options = {})
if options['policy']
- options['policy'] = Base64.encode64(MultiJson.dump(options['policy'])).gsub("\n", "")
+ options['policy'] = Base64.encode64(Fog::JSON.encode(options['policy'])).gsub("\n", "")
options['AWSAccessKeyId'] = @aws_access_key_id
options['Signature'] = Base64.encode64(@hmac.sign(options['policy'])).gsub("\n", "")
end
View
2 lib/fog/aws/requests/storage/put_bucket_policy.rb
@@ -14,7 +14,7 @@ class Real
def put_bucket_policy(bucket_name, policy)
request({
- :body => MultiJson.dump(policy),
+ :body => Fog::JSON.encode(policy),
:expects => 204,
:headers => {},
:host => "#{bucket_name}.#{@host}",
View
2 lib/fog/aws/requests/sts/get_federation_token.rb
@@ -9,7 +9,7 @@ def get_federation_token(name, policy, duration=43200)
request({
'Action' => 'GetFederationToken',
'Name' => name,
- 'Policy' => MultiJson.dump(policy),
+ 'Policy' => Fog::JSON.encode(policy),
'DurationSeconds' => duration,
:idempotent => true,
:parser => Fog::Parsers::AWS::STS::GetSessionToken.new
View
1 lib/fog/aws/sns.rb
@@ -49,7 +49,6 @@ class Real
# ==== Returns
# * SNS object with connection to AWS.
def initialize(options={})
- require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
View
1 lib/fog/aws/storage.rb
@@ -195,7 +195,6 @@ def self.reset
def initialize(options={})
require 'mime/types'
- require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
options[:region] ||= 'us-east-1'
View
1 lib/fog/aws/sts.rb
@@ -66,7 +66,6 @@ class Real
# * STS object with connection to AWS.
def initialize(options={})
require 'fog/core/parser'
- require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
View
3 lib/fog/bluebox/compute.rb
@@ -62,7 +62,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@bluebox_api_key = options[:bluebox_api_key]
@bluebox_customer_id = options[:bluebox_customer_id]
@connection_options = options[:connection_options] || {}
@@ -94,7 +93,7 @@ def request(params)
end
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
2 lib/fog/bluebox/models/compute/server.rb
@@ -121,7 +121,7 @@ def setup(credentials = {})
%{mkdir .ssh},
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
%{passwd -l #{username}},
- %{echo "#{MultiJson.dump(attributes)}" >> ~/attributes.json}
+ %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}
])
rescue Errno::ECONNREFUSED
sleep(1)
View
9 lib/fog/brightbox/compute.rb
@@ -117,7 +117,6 @@ def request(options)
class Real
def initialize(options)
- require 'multi_json'
# Currently authentication and api endpoints are the same but may change
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
@@ -134,7 +133,7 @@ def request(method, url, expected_responses, options = nil)
:path => url,
:expects => expected_responses
}
- request_options[:body] = MultiJson.dump(options) unless options.nil?
+ request_options[:body] = Fog::JSON.encode(options) unless options.nil?
make_request(request_options)
end
@@ -147,7 +146,7 @@ def get_oauth_token(options = {})
auth_url = options[:brightbox_auth_url] || @auth_url
connection = Fog::Connection.new(auth_url)
- @authentication_body = MultiJson.dump({'client_id' => @brightbox_client_id, 'grant_type' => 'none'})
+ @authentication_body = Fog::JSON.encode({'client_id' => @brightbox_client_id, 'grant_type' => 'none'})
response = connection.request({
:path => "/token",
@@ -159,7 +158,7 @@ def get_oauth_token(options = {})
:method => 'POST',
:body => @authentication_body
})
- @oauth_token = MultiJson.load(response.body)["access_token"]
+ @oauth_token = Fog::JSON.decode(response.body)["access_token"]
return @oauth_token
end
@@ -172,7 +171,7 @@ def make_request(params)
response = authenticated_request(params)
end
unless response.body.empty?
- response = MultiJson.load(response.body)
+ response = Fog::JSON.decode(response.body)
end
end
View
2 lib/fog/brightbox/requests/compute/resize_server.rb
@@ -9,7 +9,7 @@ def resize_server(identifier, options = {})
:method => 'POST',
:path => "/1.0/servers/#{identifier}/resize",
:headers => {"Content-Type" => "application/json"},
- :body => MultiJson.dump(options)
+ :body => Fog::JSON.encode(options)
)
end
View
4 lib/fog/clodo/compute.rb
@@ -57,7 +57,6 @@ def self.reset
end
def initialize(options={})
- require 'multi_json'
@clodo_username = options[:clodo_username]
end
@@ -74,7 +73,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@clodo_api_key = options[:clodo_api_key]
@clodo_username = options[:clodo_username]
@clodo_auth_url = options[:clodo_auth_url]
@@ -119,7 +117,7 @@ def request(params)
end
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
2 lib/fog/clodo/models/compute/server.rb
@@ -121,7 +121,7 @@ def setup(credentials = {})
%{mkdir .ssh},
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
%{passwd -l #{username}},
- %{echo "#{MultiJson.dump(attributes)}" >> ~/attributes.json},
+ %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
])
rescue Errno::ECONNREFUSED
sleep(1)
View
2 lib/fog/clodo/requests/compute/create_server.rb
@@ -30,7 +30,7 @@ def create_server(image_id, options = {})
data['server'].merge! options if options
request(
- :body => MultiJson.dump(data),
+ :body => Fog::JSON.encode(data),
:expects => [200, 202],
:method => 'POST',
:path => 'servers'
View
2 lib/fog/clodo/requests/compute/delete_ip_address.rb
@@ -19,7 +19,7 @@ def delete_ip_address(server_id, ip)
:expects => [204],
:method => 'DELETE',
:path => "servers/#{server_id}/ips",
- :body => MultiJson.dump(data)
+ :body => Fog::JSON.encode(data)
)
end
end
View
2 lib/fog/clodo/requests/compute/move_ip_address.rb
@@ -17,7 +17,7 @@ def move_ip_address(server_id, ip)
:expects => [204],
:method => 'GET',
:path => "servers/#{server_id}/ips/moveip",
- :body => MultiJson.dump({'ip'=>"#{ip}"})
+ :body => Fog::JSON.encode({'ip'=>"#{ip}"})
)
end
end
View
2 lib/fog/clodo/requests/compute/server_action.rb
@@ -4,7 +4,7 @@ class Clodo
class Real
def server_action(id, action)
request(
- :body => MultiJson.dump(action),
+ :body => Fog::JSON.encode(action),
:expects => [204],
:method => 'POST',
:path => "servers/#{id}/action")
View
7 lib/fog/cloudstack/compute.rb
@@ -135,7 +135,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@cloudstack_api_key = options[:cloudstack_api_key]
@cloudstack_secret_access_key = options[:cloudstack_secret_access_key]
@cloudstack_session_id = options[:cloudstack_session_id]
@@ -165,7 +164,7 @@ def login(username,password,domain)
sessionid = cookies['JSESSIONID'].first
# Decode the login response
- response = MultiJson.load(response.body)
+ response = Fog::JSON.decode(response.body)
user = response['loginresponse']
user.merge!('sessionid' => sessionid)
@@ -188,7 +187,7 @@ def request(params)
end
response = issue_request(params,headers)
- response = MultiJson.load(response.body) unless response.body.empty?
+ response = Fog::JSON.decode(response.body) unless response.body.empty?
response
end
@@ -232,7 +231,7 @@ def issue_request(params={},headers={},method='GET',expects=200)
})
rescue Excon::Errors::HTTPStatusError => error
- error_response = MultiJson.load(error.response.body)
+ error_response = Fog::JSON.decode(error.response.body)
error_code = error_response.values.first['errorcode']
error_text = error_response.values.first['errortext']
View
3 lib/fog/core/collection.rb
@@ -121,8 +121,7 @@ def table(attributes = nil)
end
def to_json(options = {})
- require 'multi_json'
- MultiJson.dump(self.map {|member| member.attributes})
+ Fog::JSON.encode(self.map {|member| member.attributes})
end
private
View
26 lib/fog/core/json.rb
@@ -1,3 +1,5 @@
+require 'multi_json'
+
module Fog
module JSON
@@ -16,5 +18,29 @@ def self.sanitize(data)
end
end
+ # Do the MultiJson introspection at this level so we can define our encode/decode methods and perform
+ # the introspection only once rather than once per call.
+
+ if MultiJson.respond_to?(:dump)
+ def self.encode(obj)
+ MultiJson.encode(obj)
+ end
+ else
+ def self.encode(obj)
+ MultiJson.encode(obj)
+ end
+ end
+
+ if MultiJson.respond_to?(:load)
+ def self.decode(obj)
+ Fog::JSON.decode(obj)
+ end
+ else
+ def self.decode(obj)
+ MultiJson.decode(obj)
+ end
+ end
+
+
end
end
View
3 lib/fog/core/model.rb
@@ -38,8 +38,7 @@ def reload
end
def to_json(options = {})
- require 'multi_json'
- MultiJson.dump(attributes)
+ Fog::JSON.encode(attributes)
end
def symbolize_keys(hash)
View
4 lib/fog/dnsimple/dns.rb
@@ -55,8 +55,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
-
@dnsimple_email = options[:dnsimple_email]
@dnsimple_password = options[:dnsimple_password]
@connection_options = options[:connection_options] || {}
@@ -87,7 +85,7 @@ def request(params)
response = @connection.request(params.merge!({:host => @host}))
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
2 lib/fog/dnsimple/requests/dns/create_domain.rb
@@ -14,7 +14,7 @@ class Real
def create_domain(name)
body = { "domain" => { "name" => name } }
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:expects => 201,
:method => 'POST',
:path => '/domains'
View
2 lib/fog/dnsimple/requests/dns/create_record.rb
@@ -36,7 +36,7 @@ def create_record(domain, name, type, content, options = {})
body["record"].merge!(options)
- request( :body => MultiJson.dump(body),
+ request( :body => Fog::JSON.encode(body),
:expects => 201,
:method => 'POST',
:path => "/domains/#{domain}/records" )
View
2 lib/fog/dnsimple/requests/dns/update_record.rb
@@ -30,7 +30,7 @@ def update_record(domain, record_id, options)
body = { "record" => options }
- request( :body => MultiJson.dump(body),
+ request( :body => Fog::JSON.encode(body),
:expects => 200,
:method => "PUT",
:path => "/domains/#{domain}/records/#{record_id}" )
View
3 lib/fog/dnsmadeeasy/dns.rb
@@ -80,7 +80,6 @@ class Real
# * dns object with connection to aws.
def initialize(options={})
require 'fog/core/parser'
- require 'multi_json'
@dnsmadeeasy_api_key = options[:dnsmadeeasy_api_key]
@dnsmadeeasy_secret_key = options[:dnsmadeeasy_secret_key]
@@ -119,7 +118,7 @@ def request(params)
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
View
2 lib/fog/dnsmadeeasy/requests/dns/create_record.rb
@@ -52,7 +52,7 @@ def create_record(domain, name, type, data, options = {})
:expects => 201,
:method => "POST",
:path => "/V1.2/domains/#{domain}/records",
- :body => MultiJson.dump(body)
+ :body => Fog::JSON.encode(body)
)
end
View
2 lib/fog/dnsmadeeasy/requests/dns/create_secondary.rb
@@ -26,7 +26,7 @@ def create_secondary(secondary_name, ip_addresses)
:expects => 201,
:method => 'PUT',
:path => "/V1.2/secondary/#{secondary_name}",
- :body => MultiJson.dump(body)
+ :body => Fog::JSON.encode(body)
)
end
View
2 lib/fog/dnsmadeeasy/requests/dns/update_record.rb
@@ -46,7 +46,7 @@ def update_record(domain, record_id, options = {})
:expects => 200,
:method => "PUT",
:path => "/V1.2/domains/#{domain}/records/#{record_id}",
- :body => MultiJson.dump(options)
+ :body => Fog::JSON.encode(options)
)
end
View
2 lib/fog/dnsmadeeasy/requests/dns/update_secondary.rb
@@ -26,7 +26,7 @@ def update_secondary(secondary_name, ip_addresses)
:expects => 201,
:method => 'PUT',
:path => "/V1.2/secondary/#{secondary_name}",
- :body => MultiJson.dump(body)
+ :body => Fog::JSON.encode(body)
)
end
View
4 lib/fog/dynect/dns.rb
@@ -60,8 +60,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
-
@dynect_customer = options[:dynect_customer]
@dynect_username = options[:dynect_username]
@dynect_password = options[:dynect_password]
@@ -95,7 +93,7 @@ def request(params)
if response.status == 307
response = poll_job(response)
elsif !response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
View
2 lib/fog/dynect/requests/dns/post_record.rb
@@ -15,7 +15,7 @@ class Real
def post_record(type, zone, fqdn, rdata, options = {})
options.merge!('rdata' => rdata)
request(
- :body => MultiJson.dump(options),
+ :body => Fog::JSON.encode(options),
:expects => 200,
:method => :post,
:path => ["#{type.to_s.upcase}Record", zone, fqdn].join('/')
View
2 lib/fog/dynect/requests/dns/post_session.rb
@@ -8,7 +8,7 @@ def post_session
:expects => 200,
:method => :post,
:path => "Session",
- :body => MultiJson.dump({
+ :body => Fog::JSON.encode({
:customer_name => @dynect_customer,
:user_name => @dynect_username,
:password => @dynect_password
View
2 lib/fog/dynect/requests/dns/post_zone.rb
@@ -13,7 +13,7 @@ class Real
# * serial_style<~String> - style of serial number, in ['day', 'epoch', 'increment', 'minute']. Defaults to increment
def post_zone(rname, ttl, zone, options = {})
- body = MultiJson.dump({
+ body = Fog::JSON.encode({
:rname => rname,
:token => auth_token,
:ttl => ttl
View
2 lib/fog/dynect/requests/dns/put_zone.rb
@@ -14,7 +14,7 @@ class Real
def put_zone(zone, options = {})
request(
- :body => MultiJson.dump(options),
+ :body => Fog::JSON.encode(options),
:expects => 200,
:method => :put,
:path => 'Zone/' << zone
View
3 lib/fog/glesys/compute.rb
@@ -65,7 +65,6 @@ def reset_data
class Real
def initialize(options)
- require 'multi_json'
require 'base64'
@api_url = options[:glesys_api_url] || Fog.credentials[:glesys_api_url] || API_URL
@@ -94,7 +93,7 @@ def request(method_name, options = {})
}
)
- data.body = MultiJson.load(data.body)
+ data.body = Fog::JSON.decode(data.body)
response_code = data.body['response']['status']['code']
View
3 lib/fog/go_grid/compute.rb
@@ -61,7 +61,6 @@ class Real
def initialize(options={})
require 'digest/md5'
- require 'multi_json'
@go_grid_api_key = options[:go_grid_api_key]
@go_grid_shared_secret = options[:go_grid_shared_secret]
@connection_options = options[:connection_options] || {}
@@ -105,7 +104,7 @@ def request(params)
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
View
4 lib/fog/go_grid/models/compute/server.rb
@@ -76,8 +76,8 @@ def setup(credentials = {})
%{mkdir .ssh},
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
%{passwd -l root},
- %{echo "#{MultiJson.dump(attributes)}" >> ~/attributes.json},
- %{echo "#{MultiJson.dump(metadata)}" >> ~/metadata.json}
+ %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
+ %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
])
rescue Errno::ECONNREFUSED
sleep(1)
View
6 lib/fog/hp.rb
@@ -13,7 +13,7 @@ def self.slurp(error)
data = nil
message = nil
else
- data = MultiJson.load(error.response.body)
+ data = Fog::JSON.decode(error.response.body)
message = data['message']
end
@@ -144,12 +144,12 @@ def self.authenticate_v2(options, connection_options = {})
:host => @host,
:port => @port,
:method => 'POST',
- :body => MultiJson.dump(request_body),
+ :body => Fog::JSON.encode(request_body),
:path => @auth_path
}
)
- body = MultiJson.load(response.body)
+ body = Fog::JSON.decode(response.body)
### fish out auth_token and endpoint for the service
auth_token = body['access']['token']['id']
View
3 lib/fog/hp/cdn.rb
@@ -54,7 +54,6 @@ class Real
include Utils
def initialize(options={})
- require 'multi_json'
@connection_options = options[:connection_options] || {}
### Set an option to use the style of authentication desired; :v1 or :v2 (default)
auth_version = options[:hp_auth_version] || :v2
@@ -119,7 +118,7 @@ def request(params, parse_json = true, &block)
end
end
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
3 lib/fog/hp/compute.rb
@@ -105,7 +105,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@hp_secret_key = options[:hp_secret_key]
@hp_account_id = options[:hp_account_id]
@hp_servicenet = options[:hp_servicenet]
@@ -167,7 +166,7 @@ def request(params, parse_json = true, &block)
end
unless response.body.empty?
begin
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
rescue MultiJson::DecodeError => error
response.body #### the body is not in JSON format so just return it as it is
end
View
4 lib/fog/hp/models/compute/server.rb
@@ -199,8 +199,8 @@ def setup(credentials = {})
%{mkdir .ssh},
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
%{passwd -l #{username}},
- %{echo "#{MultiJson.dump(attributes)}" >> ~/attributes.json},
- %{echo "#{MultiJson.dump(metadata)}" >> ~/metadata.json}
+ %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
+ %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
])
rescue Errno::ECONNREFUSED
sleep(1)
View
2 lib/fog/hp/requests/compute/create_key_pair.rb
@@ -37,7 +37,7 @@ def create_key_pair(key_name, public_key = nil)
end
request(
- :body => MultiJson.dump(data),
+ :body => Fog::JSON.encode(data),
:expects => 200,
:method => 'POST',
:path => 'os-keypairs.json'
View
2 lib/fog/hp/requests/compute/create_security_group.rb
@@ -38,7 +38,7 @@ def create_security_group(name, description)
}
request(
- :body => MultiJson.dump(data),
+ :body => Fog::JSON.encode(data),
:expects => 200,
:method => 'POST',
:path => 'os-security-groups.json'
View
2 lib/fog/hp/requests/compute/create_security_group_rule.rb
@@ -31,7 +31,7 @@ def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port,
}
request(
- :body => MultiJson.dump(data),
+ :body => Fog::JSON.encode(data),
:expects => 200,
:method => 'POST',
:path => 'os-security-group-rules.json'
View
2 lib/fog/hp/requests/compute/create_server.rb
@@ -86,7 +86,7 @@ def create_server(name, flavor_id, image_id, options = {})
end
request(
- :body => MultiJson.dump(data),
+ :body => Fog::JSON.encode(data),
:expects => 202,
:method => 'POST',
:path => 'servers.json'
View
2 lib/fog/hp/requests/compute/server_action.rb
@@ -12,7 +12,7 @@ class Real
#
def server_action(server_id, body, expects=202)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:expects => expects,
:method => 'POST',
:path => "servers/#{server_id}/action.json"
View
2 lib/fog/hp/requests/compute/update_server.rb
@@ -12,7 +12,7 @@ class Real
# * name<~String> - New name for server
def update_server(server_id, options = {})
request(
- :body => MultiJson.dump({ 'server' => options }),
+ :body => Fog::JSON.encode({ 'server' => options }),
:expects => 200,
:method => 'PUT',
:path => "servers/#{server_id}.json"
View
3 lib/fog/hp/storage.rb
@@ -126,7 +126,6 @@ class Real
def initialize(options={})
require 'mime/types'
- require 'multi_json'
@hp_secret_key = options[:hp_secret_key]
@hp_account_id = options[:hp_account_id]
@hp_auth_uri = options[:hp_auth_uri]
@@ -189,7 +188,7 @@ def request(params, parse_json = true, &block)
end
end
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
3 lib/fog/ibm.rb
@@ -18,7 +18,6 @@ def self.timeout
class Connection < Fog::Connection
def initialize(user, password)
- require 'multi_json'
@user = user
@password = password
@endpoint = URI.parse('https://www-147.ibm.com/computecloud/enterprise/api/rest/20100331')
@@ -38,7 +37,7 @@ def request(options)
end
response = super(options)
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
5 lib/fog/joyent/compute.rb
@@ -1,7 +1,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'joyent'))
require File.expand_path(File.join(File.dirname(__FILE__), 'errors'))
require 'fog/compute'
-require 'multi_json'
module Fog
module Compute
@@ -144,7 +143,7 @@ def request(request = {})
}.merge(request[:headers] || {}).merge(@header_method.call)
if request[:body]
- request[:body] = MultiJson.dump(request[:body])
+ request[:body] = Fog::JSON.encode(request[:body])
end
response = @connection.request(request)
@@ -161,7 +160,7 @@ def request(request = {})
private
def json_decode(body)
- parsed = MultiJson.load(body)
+ parsed = Fog::JSON.decode(body)
decode_time_attrs(parsed)
end
View
3 lib/fog/libvirt/models/compute/server.rb
@@ -192,7 +192,6 @@ def scp(local_path, remote_path, upload_options = {})
# Sets up a new key
def setup(credentials = {})
requires :public_key, :public_ip_address, :username
- require 'multi_json'
credentials[:proxy]= ssh_proxy unless ssh_proxy.nil?
credentials[:password] = password unless self.password.nil?
@@ -201,7 +200,7 @@ def setup(credentials = {})
commands = [
%{mkdir .ssh},
# %{passwd -l #{username}}, #Not sure if we need this here
- # %{echo "#{MultiJson.dump(attributes)}" >> ~/attributes.json}
+ # %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}
]
if public_key
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
View
3 lib/fog/linode/compute.rb
@@ -80,7 +80,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@linode_api_key = options[:linode_api_key]
@host = options[:host] || "api.linode.com"
@port = options[:port] || 443
@@ -99,7 +98,7 @@ def request(params)
response = @connection.request(params.merge!({:host => @host}))
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
if data = response.body['ERRORARRAY'].first
error = case data['ERRORCODE']
when 5
View
3 lib/fog/linode/dns.rb
@@ -53,7 +53,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.linode.com"
@linode_api_key = options[:linode_api_key]
@@ -74,7 +73,7 @@ def request(params)
response = @connection.request(params.merge!({:host => @host}))
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
if data = response.body['ERRORARRAY'].first
error = case data['ERRORCODE']
when 5
View
2 lib/fog/linode/requests/compute/linode_disk_createfromstackscript.rb
@@ -15,7 +15,7 @@ def linode_disk_createfromstackscript(linode_id, script_id, distro_id, name, siz
:label => name,
:size => size,
:rootPass => password,
- :stackScriptUDFResponses => MultiJson.dump(options)
+ :stackScriptUDFResponses => Fog::JSON.encode(options)
}
)
end
View
6 lib/fog/ninefold/compute.rb
@@ -63,8 +63,6 @@ class Ninefold < Fog::Service
class Mock
def initialize(options)
- require 'multi_json'
-
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
@ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret]
@@ -78,8 +76,6 @@ def request(options)
class Real
def initialize(options)
- require 'multi_json'
-
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
@ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret]
@@ -108,7 +104,7 @@ def request(command, params, options)
# Because the response is some weird xml-json thing, we need to try and mung
# the values out with a prefix, and if there is an empty data entry return an
# empty version of the expected type (if provided)
- response = MultiJson.load(response.body)
+ response = Fog::JSON.decode(response.body)
if options.has_key? :response_prefix
keys = options[:response_prefix].split('/')
keys.each do |k|
View
6 lib/fog/openstack.rb
@@ -13,7 +13,7 @@ def self.slurp(error)
data = nil
message = nil
else
- data = MultiJson.load(error.response.body)
+ data = Fog::JSON.decode(error.response.body)
message = data['message']
end
@@ -91,12 +91,12 @@ def self.authenticate_v2(options, connection_options = {})
response = connection.request({
:expects => [200, 204],
:headers => {'Content-Type' => 'application/json'},
- :body => MultiJson.dump(req_body),
+ :body => Fog::JSON.encode(req_body),
:host => uri.host,
:method => 'POST',
:path => (uri.path and not uri.path.empty?) ? uri.path : 'v2.0'
})
- body=MultiJson.load(response.body)
+ body=Fog::JSON.decode(response.body)
if svc = body['access']['serviceCatalog'].detect{|x| x['name'] == @compute_service_name}
mgmt_url = svc['endpoints'].detect{|x| x['publicURL']}['publicURL']
View
4 lib/fog/openstack/compute.rb
@@ -87,7 +87,6 @@ def self.reset
end
def initialize(options={})
- require 'multi_json'
@openstack_username = options[:openstack_username]
end
@@ -104,7 +103,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@openstack_api_key = options[:openstack_api_key]
@openstack_username = options[:openstack_username]
@openstack_tenant = options[:openstack_tenant]
@@ -151,7 +149,7 @@ def request(params)
end
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
4 lib/fog/openstack/models/compute/server.rb
@@ -175,8 +175,8 @@ def setup(credentials = {})
%{mkdir .ssh},
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
%{passwd -l #{username}},
- %{echo "#{MultiJson.dump(attributes)}" >> ~/attributes.json},
- %{echo "#{MultiJson.dump(metadata)}" >> ~/metadata.json}
+ %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
+ %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
])
rescue Errno::ECONNREFUSED
sleep(1)
View
2 lib/fog/openstack/requests/compute/create_server.rb
@@ -29,7 +29,7 @@ def create_server(name, image_ref, flavor_ref, options = {})
end
request(
- :body => MultiJson.dump(data),
+ :body => Fog::JSON.encode(data),
:expects => [200, 202],
:method => 'POST',
:path => 'servers.json'
View
2 lib/fog/openstack/requests/compute/server_action.rb
@@ -5,7 +5,7 @@ class Real
def server_action(server_id, body, expects=202)
request(
- :body => MultiJson.dump(body),
+ :body => Fog::JSON.encode(body),
:expects => expects,
:method => 'POST',
:path => "servers/#{server_id}/action.json"
View
2 lib/fog/openstack/requests/compute/set_metadata.rb
@@ -6,7 +6,7 @@ class Real
def set_metadata(collection_name, parent_id, metadata = {})
request(
- :body => MultiJson.dump({ 'metadata' => metadata }),
+ :body => Fog::JSON.encode({ 'metadata' => metadata }),
:expects => 200,
:method => 'PUT',
:path => "#{collection_name}/#{parent_id}/metadata"
View
2 lib/fog/openstack/requests/compute/update_meta.rb
@@ -6,7 +6,7 @@ class Real
def update_meta(collection_name, parent_id, key, value)
request(
- :body => MultiJson.dump({ 'meta' => { key => value }}),
+ :body => Fog::JSON.encode({ 'meta' => { key => value }}),
:expects => 200,
:method => 'PUT',
:path => "#{collection_name}/#{parent_id}/metadata/#{key}"
View
2 lib/fog/openstack/requests/compute/update_metadata.rb
@@ -6,7 +6,7 @@ class Real
def update_metadata(collection_name, parent_id, metadata = {})
request(
- :body => MultiJson.dump({ 'metadata' => metadata }),
+ :body => Fog::JSON.encode({ 'metadata' => metadata }),
:expects => 200,
:method => 'POST',
:path => "#{collection_name}/#{parent_id}/metadata.json"
View
2 lib/fog/openstack/requests/compute/update_server.rb
@@ -5,7 +5,7 @@ class Real
def update_server(server_id, options = {})
request(
- :body => MultiJson.dump({ 'server' => options }),
+ :body => Fog::JSON.encode({ 'server' => options }),
:expects => 200,
:method => 'PUT',
:path => "servers/#{server_id}.json"
View
2 lib/fog/rackspace.rb
@@ -13,7 +13,7 @@ def self.slurp(error)
data = nil
message = nil
else
- data = MultiJson.load(error.response.body)
+ data = Fog::JSON.decode(error.response.body)
message = data['message']
end
View
3 lib/fog/rackspace/cdn.rb
@@ -45,7 +45,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@connection_options = options[:connection_options] || {}
credentials = Fog::Rackspace.authenticate(options, @connection_options)
@auth_token = credentials['X-Auth-Token']
@@ -90,7 +89,7 @@ def request(params, parse_json = true)
end
end
if !response.body.empty? && parse_json && response.headers['Content-Type'] =~ %r{application/json}
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
4 lib/fog/rackspace/compute.rb
@@ -61,7 +61,6 @@ def self.reset
end
def initialize(options={})
- require 'multi_json'
@rackspace_username = options[:rackspace_username]
end
@@ -78,7 +77,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@rackspace_auth_url = options[:rackspace_auth_url]
@@ -125,7 +123,7 @@ def request(params)
end
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
3 lib/fog/rackspace/dns.rb
@@ -73,7 +73,6 @@ def reset_data
class Real
def initialize(options={})
- require 'multi_json'
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@rackspace_auth_url = options[:rackspace_auth_url]
@@ -108,7 +107,7 @@ def request(params)
raise Fog::Rackspace::Errors::ServiceUnavailable.slurp error
end
unless response.body.empty?
- response.body = MultiJson.load(response.body)
+ response.body = Fog::JSON.decode(response.body)
end
response
end
View
3 lib/fog/rackspace/load_balancers.rb
@@ -97,7 +97,6 @@ class Real
include Shared
def initialize(options={})
- require 'multi_json'
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@rackspace_auth_url = options[:rackspace_auth_url]
@@ -136,7 +135,7 @@ def request(params)
raise ServiceError.slurp error
end
unless response.body.empty?