cloudstack_ruby_client 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWJmY2I0OWRjY2ZmOGUyZTcwMGRkZTliNzllYmViMDYwMWYyMThjMQ==
4
+ M2Y5NGUzYTlkZTg0Yzk3ZjQ0MGQxYTJhNmQ2MzQ0ZDJlNzYyYmQzZg==
5
5
  data.tar.gz: !binary |-
6
- MjJmZjMwMmM2NTg2Mjc1OWI2NWQwNzA2OTMwZWFmOGQwZDE4ZWI4ZQ==
6
+ MzllZWE4MDJmZDgxY2UzYjM0YTZmNzFkOTgwMzdiZjFkMzU5MmU5Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGU4YWY1ZjFmNDJhMWQyYzBmYTRkOGJhMWViNDI3OGQ3Y2U4ZjRiNDgxNGJh
10
- ZTcwZDllMzMxZjY1YTYzYTQxMjRkYmM4Y2EzNmZmYTRhODIxNjcxM2RhMWY0
11
- N2FhYzgxMjY1NDYzNTFiMTMyMTAyNDgzNWU5NjU1OWIyMWY3Zjc=
9
+ NWZkMTMwYTA1NGE5MDdkODhlNGU4YWQ5ZGRlMzhkODQ2MzNkOThmNmE3MzQ1
10
+ ZDJmZWRmZDQxMGNkNGNkOGU5MGJmMzIwMTE1MDEzYmMxOTEwOGVjMjEyMGIy
11
+ Y2RjOWZhYzUyNzA3ZGFmOWFjMDIyODZhNWY0Yjk2YmFhYzEzMWE=
12
12
  data.tar.gz: !binary |-
13
- YjIyMWE0NjhmODEyNTUxNmI1MWE2MDc4NmZlNjNiY2ZhYzU3MzNmNDc4M2M3
14
- ODdiNTA3ZWE2OTRjMjNiYzM5ZjlhMThiZWVjMGUxZGExNmY5MTk2ZDRkODA2
15
- ZmU1MjQyZDVkYWJjYzcxNTc0YzU4YWEzMjBlMTI4MDc2MTFlZTQ=
13
+ ZjkxYWNiNDkyYTRjYzhmNWRkNzEwZjNiOGZhODE5NDMwNWYwZjYwYzZkZjIw
14
+ ZWY5NmNmNTNiZWFiNWM1NDc5YzlhOTI1ZTgyNmI5MjEyZTQ0NWY4ZDgyZGQ3
15
+ YTA2NWE1YTk1NDViMDk0ZmQ4ZTI5NWU0NGIwNWJhMDRlN2RjNWM=
@@ -7,7 +7,11 @@ module CloudstackRubyClient
7
7
  :create_snapshot_policy,
8
8
  # FIXME: Weird deleteSnapshotPolicies command
9
9
  :delete_snapshot_policies,
10
- :list_snapshot_policies
10
+ :list_snapshot_policies,
11
+ :list_vm_snapshot,
12
+ :create_vm_snapshot,
13
+ :delete_vm_snapshot,
14
+ :revert_to_vm_snapshot
11
15
  end
12
16
  end
13
- end
17
+ end
@@ -9,22 +9,34 @@ class CloudstackRubyClient::BaseClient
9
9
  end
10
10
 
11
11
  def request(params)
12
- params['response'] = 'json'
13
- params['apiKey'] = @api_key
14
-
12
+ params[:response] = 'json'
13
+ params[:apiKey] = @api_key
14
+
15
15
  data = params.map{ |k,v| "#{k.to_s}=#{CGI.escape(v.to_s).gsub(/\+|\ /, "%20")}" }.sort.join('&')
16
-
17
16
  signature = OpenSSL::HMAC.digest 'sha1', @secret_key, data.downcase
18
17
  signature = Base64.encode64(signature).chomp
19
- signature = CGI.escape(signature)
20
18
 
21
- url = "#{@api_url}?#{data}&signature=#{signature}"
19
+ method = 'POST' if params[:userdata] and params[:userdata].size > 2048
20
+ if method == 'POST'
21
+ params[:signature] = signature
22
+ url = @api_url
23
+ else
24
+ signature = CGI.escape(signature)
25
+ url = "#{@api_url}?#{data}&signature=#{signature}"
26
+ end
27
+
22
28
  uri = URI.parse(url)
23
29
  http = Net::HTTP.new(uri.host, uri.port)
24
30
  http.use_ssl = @use_ssl
25
31
  http.open_timeout = @open_timeout # fail the connection faster if can't open socket
26
32
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
27
- request = Net::HTTP::Get.new(uri.request_uri)
33
+
34
+ if method == 'POST'
35
+ request = Net::HTTP::Post.new(uri.request_uri)
36
+ request.set_form_data(params)
37
+ else
38
+ request = Net::HTTP::Get.new(uri.request_uri)
39
+ end
28
40
 
29
41
  http.request(request)
30
42
  end
@@ -72,8 +72,8 @@ class CloudstackRubyClient::Client < CloudstackRubyClient::BaseClient
72
72
  protected
73
73
 
74
74
  def auth_request(params, command)
75
- params['response'] = 'json'
76
- params['command'] = command
75
+ params[:response] = 'json'
76
+ params[:command] = command
77
77
  data = params.map{ |k,v| "#{k.to_s}=#{CGI.escape(v.to_s).gsub(/\+|\ /, "%20")}" }.sort.join('&')
78
78
 
79
79
  url = "#{@api_url}?#{data}"
@@ -23,14 +23,18 @@ class Module
23
23
  "createlbhealthcheckpolicy" => "createLBHealthCheckPolicy",
24
24
  "deletelbhealthcheckpolicy" => "deleteLBHealthCheckPolicy",
25
25
  "createvpc" => "createVPC",
26
- "listvpcs" => "listVPCs",
27
- "deletevpc" => "deleteVPC",
26
+ "listvpcs" => "listVPCs",
27
+ "deletevpc" => "deleteVPC",
28
28
  "updatevpc" => "updateVPC",
29
29
  "restartvpc" => "restartVPC",
30
30
  "createvpcoffering" => "createVPCOffering",
31
31
  "updatevpcoffering" => "updateVPCOffering",
32
32
  "deletevpcoffering" => "deleteVPCOffering",
33
- "listvpcofferings" => "listVPCOfferings"
33
+ "listvpcofferings" => "listVPCOfferings",
34
+ "listvmsnapshot" => "listVMSnapshot",
35
+ "createvmsnapshot" => "createVMSnapshot",
36
+ "deletevmsnapshot" => "deleteVMSnapshot",
37
+ "reverttovmsnapshot" => "revertToVMSnapshot"
34
38
  }
35
39
 
36
40
  #
@@ -90,7 +94,7 @@ class Module
90
94
  } +
91
95
 
92
96
  %Q{
93
- params = {'command' => command};
97
+ params = {:command => command};
94
98
  params.merge!(args) unless args.empty?;
95
99
 
96
100
  response = request(params);
@@ -1,3 +1,3 @@
1
1
  module CloudstackRubyClient
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -20,7 +20,7 @@ class SnapshotTest < Test::Unit::TestCase
20
20
  def teardown
21
21
  # Do nothing here!
22
22
  end
23
-
23
+
24
24
  ### Snapshot ###
25
25
  def test_create_snapshot
26
26
  assert_raise(ArgumentError) do
@@ -49,4 +49,28 @@ class SnapshotTest < Test::Unit::TestCase
49
49
  @client.list_snapshot_policies
50
50
  end
51
51
  end
52
+
53
+ def test_list_vm_snapshot
54
+ assert_raise(ArgumentError) do
55
+ @client.list_vm_snapshot
56
+ end
57
+ end
58
+
59
+ def test_create_vm_snapshot
60
+ assert_raise(ArgumentError) do
61
+ @client.create_vm_snapshot
62
+ end
63
+ end
64
+
65
+ def test_delete_vm_snapshot
66
+ assert_raise(ArgumentError) do
67
+ @client.delete_vm_snapshot
68
+ end
69
+ end
70
+
71
+ def test_revert_to_vm_snapshot
72
+ assert_raise(ArgumentError) do
73
+ @client.revert_to_vm_snapshot
74
+ end
75
+ end
52
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack_ruby_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chip Childers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2016-02-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby client for CloudStack's API, including a simple CLI.
14
14
  email: