ultravault 1.0.2.0 → 1.2.0
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.
- data/lib/ultravault.rb +3 -1
- data/lib/ultravault/data_objects/agent.rb +6 -2
- data/lib/ultravault/data_objects/disk_safe.rb +17 -4
- data/lib/ultravault/data_objects/policy.rb +22 -0
- data/lib/ultravault/soap_service/disk_safe_service.rb +10 -1
- data/lib/ultravault/soap_service/policy_service.rb +24 -0
- data/test/support/fixtures.rb +2 -1
- data/test/support/fixtures/policy_service.rb +58 -0
- data/test/test_helper.rb +3 -1
- data/test/unit/lib/ultravault/data_objects/test_agent.rb +18 -1
- data/test/unit/lib/ultravault/soap_service/test_policy_service.rb +61 -0
- data/ultravault.gemspec +2 -2
- metadata +10 -7
data/lib/ultravault.rb
CHANGED
@@ -13,5 +13,7 @@ module UltraVault
|
|
13
13
|
autoload :RecoveryPoint, "ultravault/data_objects/recovery_point"
|
14
14
|
autoload :RecoveryPointService, "ultravault/soap_service/recovery_point_service"
|
15
15
|
autoload :SoapService, "ultravault/soap_service"
|
16
|
+
autoload :Policy, "ultravault/data_objects/policy"
|
17
|
+
autoload :PolicyService, "ultravault/soap_service/policy_service"
|
16
18
|
|
17
|
-
end
|
19
|
+
end
|
@@ -16,7 +16,11 @@ module UltraVault
|
|
16
16
|
# @return [[UltraVault::DiskSafe]] disk safes for this agent
|
17
17
|
# @raise [Savon::SOAP::Fault] errors from the soap transaction
|
18
18
|
def disk_safes
|
19
|
-
|
19
|
+
if UltraVault.config.api_version > 1
|
20
|
+
@disk_safes ||= UltraVault::DiskSafe.all.map { |disk_safe| disk_safe if disk_safe.agent_id == id }.compact
|
21
|
+
else
|
22
|
+
@disk_safes ||= UltraVault::DiskSafe.find_all_by_agent_id(id)
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
# Returns an agent, if found.
|
@@ -101,4 +105,4 @@ module UltraVault
|
|
101
105
|
end
|
102
106
|
|
103
107
|
end
|
104
|
-
end
|
108
|
+
end
|
@@ -11,8 +11,8 @@ module UltraVault
|
|
11
11
|
@compression_type = params[:compression_type]
|
12
12
|
@description = params[:description]
|
13
13
|
@device_count = params[:device_count].to_i
|
14
|
-
@device_list = [params[:device_list]].flatten.collect do |device|
|
15
|
-
DeviceList.new(device)
|
14
|
+
@device_list = [params[:device_list]].flatten.collect do |device|
|
15
|
+
DeviceList.new(device) if device
|
16
16
|
end
|
17
17
|
@id = params[:id]
|
18
18
|
@open = params[:open]
|
@@ -21,11 +21,16 @@ module UltraVault
|
|
21
21
|
@size_of_deltas = params[:size_of_deltas_in_disk_safe].to_i
|
22
22
|
@volume_id = params[:volume_id]
|
23
23
|
extract_attributes params[:disk_safe_attribute_map]
|
24
|
+
super(params)
|
24
25
|
end
|
25
26
|
|
26
27
|
def recovery_points
|
27
28
|
@recovery_points ||= UltraVault::RecoveryPointService.new.find_recovery_points_by_disk_safe_id(id)
|
28
29
|
end
|
30
|
+
|
31
|
+
def policies
|
32
|
+
@policies ||= UltraVault::Policy.all.map { |policy| policy if policy.disk_safe_id == id }.compact
|
33
|
+
end
|
29
34
|
|
30
35
|
# Returns an array of disk safes, if found.
|
31
36
|
#
|
@@ -34,7 +39,15 @@ module UltraVault
|
|
34
39
|
# @raise [Savon::SOAP::Fault] errors from the soap transaction
|
35
40
|
def self.find_all_by_agent_id(agent_id)
|
36
41
|
UltraVault::DiskSafeService.new.find_disksafes_by_agent_id agent_id
|
37
|
-
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns all disk safes for the current user.
|
45
|
+
#
|
46
|
+
# @return [[UltraVault::DiskSafe]] current user's disk safes
|
47
|
+
# @raise [Savon::SOAP::Fault] errors from the soap transaction
|
48
|
+
def self.all
|
49
|
+
UltraVault::DiskSafeService.new.all_disk_safes
|
50
|
+
end
|
38
51
|
|
39
52
|
private
|
40
53
|
|
@@ -61,4 +74,4 @@ module UltraVault
|
|
61
74
|
|
62
75
|
end
|
63
76
|
end
|
64
|
-
end
|
77
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module UltraVault
|
2
|
+
class Policy < OpenStruct
|
3
|
+
|
4
|
+
# Returns an agent, if found.
|
5
|
+
#
|
6
|
+
# @param [String] policy_id the UUID of the policy
|
7
|
+
# @return [UltraVault::Policy] the policy matching the policy_id
|
8
|
+
# @raise [Savon::SOAP::Fault] errors from the soap transaction
|
9
|
+
def self.find_by_id(policy_id)
|
10
|
+
UltraVault::PolicyService.new.find_policy_by_id(policy_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns all policies for the current user.
|
14
|
+
#
|
15
|
+
# @return [[UltraVault::Policy]] current user's policies
|
16
|
+
# @raise [Savon::SOAP::Fault] errors from the soap transaction
|
17
|
+
def self.all
|
18
|
+
UltraVault::PolicyService.new.all_policies
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -14,5 +14,14 @@ module UltraVault
|
|
14
14
|
UltraVault::DiskSafe.new(disk_safe)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def all_disk_safes
|
19
|
+
response_hash = client.request(:getDiskSafes).to_hash
|
20
|
+
params = extract_params_array(response_hash,
|
21
|
+
:get_disk_safes_response)
|
22
|
+
params.collect do |disk_safe|
|
23
|
+
UltraVault::DiskSafe.new(disk_safe)
|
24
|
+
end
|
25
|
+
end
|
17
26
|
end
|
18
|
-
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module UltraVault
|
2
|
+
# @private
|
3
|
+
class PolicyService < UltraVault::SoapService
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
super(:Policy)
|
7
|
+
end
|
8
|
+
|
9
|
+
def find_policy_by_id(policy_id)
|
10
|
+
response_hash = client.request(:getPolicyById, :id => policy_id).to_hash
|
11
|
+
params = extract_params(response_hash, :get_policy_by_id_response)
|
12
|
+
UltraVault::Policy.new(params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def all_policies
|
16
|
+
response_hash = client.request(:getPolicies).to_hash
|
17
|
+
params = extract_params_array(response_hash,
|
18
|
+
:get_policies_response)
|
19
|
+
params.collect do |policy|
|
20
|
+
UltraVault::Policy.new(policy)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/test/support/fixtures.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'fixtures/agent_service'
|
2
2
|
require_relative 'fixtures/disk_safe'
|
3
3
|
require_relative 'fixtures/disk_safe_service'
|
4
|
-
require_relative 'fixtures/recovery_point_service'
|
4
|
+
require_relative 'fixtures/recovery_point_service'
|
5
|
+
require_relative 'fixtures/policy_service'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module UltraVault
|
2
|
+
module Fixtures
|
3
|
+
def load_policy_service_fixtures
|
4
|
+
@policy_by_id = { :description=>nil,
|
5
|
+
:disk_safe_id=>"d1da6e8c-392f-4918-b780-6e5a5d62dd39",
|
6
|
+
:enabled=>true,
|
7
|
+
:force_full_block_scan=>false,
|
8
|
+
:frequency_type=>"DAILY",
|
9
|
+
:frequency_values=>{:hours_of_day=>"4", :starting_minute=>"0"},
|
10
|
+
:id=>"04071ece-4129-4623-b008-05d9b9a67a32",
|
11
|
+
:name=>"melbourne-kickstart",
|
12
|
+
:recovery_point_limit=>"10",
|
13
|
+
:state=>"OK"
|
14
|
+
}
|
15
|
+
|
16
|
+
@policy_by_id_wrapper = {
|
17
|
+
:get_policy_by_id_response=>
|
18
|
+
{
|
19
|
+
:return=> @policy_by_id,
|
20
|
+
:"@xmlns:ns1"=>"http://policy.api.server.backup.r1soft.com/"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
@all_policies = [
|
25
|
+
{ :description=>nil,
|
26
|
+
:disk_safe_id=>"d1da6e8c-392f-4918-b780-6e5a5d62dd39",
|
27
|
+
:enabled=>true,
|
28
|
+
:force_full_block_scan=>false,
|
29
|
+
:frequency_type=>"DAILY",
|
30
|
+
:frequency_values=>{:hours_of_day=>"4", :starting_minute=>"0"},
|
31
|
+
:id=>"04071ece-4129-4623-b008-05d9b9a67a32",
|
32
|
+
:name=>"melbourne-kickstart",
|
33
|
+
:recovery_point_limit=>"10",
|
34
|
+
:state=>"OK"
|
35
|
+
},
|
36
|
+
{ :description=>nil,
|
37
|
+
:disk_safe_id=>"d1da6e8c-392f-4918-b780-6e5a5d62dd39",
|
38
|
+
:enabled=>true,
|
39
|
+
:force_full_block_scan=>false,
|
40
|
+
:frequency_type=>"DAILY",
|
41
|
+
:frequency_values=>{:hours_of_day=>"4", :starting_minute=>"0"},
|
42
|
+
:id=>"d1da6e8c-4129-4623-b780-05d9b9a67a32",
|
43
|
+
:name=>"melbourne-kickstart2",
|
44
|
+
:recovery_point_limit=>"10",
|
45
|
+
:state=>"OK"
|
46
|
+
}
|
47
|
+
]
|
48
|
+
|
49
|
+
@all_policies_wrapper = {
|
50
|
+
:get_policies_response=>
|
51
|
+
{
|
52
|
+
:return=> @all_policies,
|
53
|
+
:"@xmlns:ns1"=>"http://policy.api.server.backup.r1soft.com/"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -20,6 +20,8 @@ require_relative '../lib/ultravault/soap_service'
|
|
20
20
|
require_relative '../lib/ultravault/soap_service/agent_service'
|
21
21
|
require_relative '../lib/ultravault/soap_service/disk_safe_service'
|
22
22
|
require_relative '../lib/ultravault/soap_service/recovery_point_service'
|
23
|
+
require_relative '../lib/ultravault/soap_service/policy_service'
|
24
|
+
require_relative '../lib/ultravault/data_objects/policy'
|
23
25
|
|
24
26
|
require_relative 'support/fixtures'
|
25
27
|
|
@@ -32,4 +34,4 @@ UltraVault.configure do |config|
|
|
32
34
|
config.ssl = false
|
33
35
|
config.username = 'foo'
|
34
36
|
config.password = 'bar'
|
35
|
-
end
|
37
|
+
end
|
@@ -44,6 +44,23 @@ module UltraVault
|
|
44
44
|
@params[:id]).returns(stub)
|
45
45
|
@agent.disk_safes
|
46
46
|
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with an API version > 1' do
|
51
|
+
|
52
|
+
setup do
|
53
|
+
UltraVault.configure do |config|
|
54
|
+
config.api_version = 2
|
55
|
+
end
|
56
|
+
@agent = Agent.new(@params)
|
57
|
+
end
|
58
|
+
|
59
|
+
should "respond to .disk_safes via an api call" do
|
60
|
+
DiskSafe.expects(:all).returns(Array.new)
|
61
|
+
assert_equal 2, UltraVault.config.api_version
|
62
|
+
@agent.disk_safes
|
63
|
+
end
|
47
64
|
|
48
65
|
end
|
49
66
|
|
@@ -130,4 +147,4 @@ module UltraVault
|
|
130
147
|
end
|
131
148
|
end
|
132
149
|
end
|
133
|
-
end
|
150
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative '../../../../test_helper'
|
2
|
+
|
3
|
+
module UltraVault
|
4
|
+
class PolicyServiceTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context 'a new policy service' do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
load_policy_service_fixtures
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'public methods' do
|
13
|
+
|
14
|
+
setup do
|
15
|
+
ApiRequest.expects(:new).returns(stub(endpoint: 'foo',
|
16
|
+
namespace: 'bar'))
|
17
|
+
@service = PolicyService.new
|
18
|
+
@client = stub
|
19
|
+
@service.expects(:client).returns(@client)
|
20
|
+
@error = Savon::SOAP::Fault.new(stub(body: 'foo'))
|
21
|
+
end
|
22
|
+
|
23
|
+
context '#find_policy_by_id' do
|
24
|
+
should "return a policy object if it exists" do
|
25
|
+
@client.expects(:request).with(
|
26
|
+
:getPolicyById, id: 'foo').returns(mock(to_hash: @policy_by_id_wrapper))
|
27
|
+
Policy.expects(:new).returns(stub_everything)
|
28
|
+
policy = @service.find_policy_by_id('foo')
|
29
|
+
end
|
30
|
+
|
31
|
+
should "raise an error if it does not exist" do
|
32
|
+
@client.expects(:request).with(
|
33
|
+
:getPolicyById, id: 'bar').raises(@error)
|
34
|
+
assert_raise Savon::SOAP::Fault do
|
35
|
+
policy = @service.find_policy_by_id('bar')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#all_policies' do
|
41
|
+
should "return all policies available" do
|
42
|
+
@client.expects(:request).with(:getPolicies).returns(
|
43
|
+
mock(to_hash: @all_policies_wrapper))
|
44
|
+
Policy.expects(:new).at_least_once.returns(stub_everything)
|
45
|
+
policies = @service.all_policies
|
46
|
+
end
|
47
|
+
|
48
|
+
should "raise an error if something goes wrong" do
|
49
|
+
@client.expects(:request).with(:getPolicies).raises(@error)
|
50
|
+
assert_raise Savon::SOAP::Fault do
|
51
|
+
agent = @service.all_policies
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
data/ultravault.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "ultravault"
|
3
|
-
gem.version = "1.
|
3
|
+
gem.version = "1.2.0"
|
4
4
|
|
5
5
|
gem.homepage = "http://github.com/melbourne/ultravault"
|
6
6
|
gem.summary = "UltraVault"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_development_dependency "vcr"
|
19
19
|
gem.add_development_dependency "simplecov"
|
20
20
|
|
21
|
-
gem.add_dependency "savon"
|
21
|
+
gem.add_dependency "savon", "~> 0.9.9"
|
22
22
|
|
23
23
|
gem.author = "Carpet & Sean"
|
24
24
|
gem.email = "andrew.turner@melbourne.co.uk;sean.handley@melbourne.co.uk"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultravault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -128,17 +128,17 @@ dependencies:
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
133
|
+
version: 0.9.9
|
134
134
|
type: :runtime
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
141
|
+
version: 0.9.9
|
142
142
|
description: ! ' UltraVault Interface
|
143
143
|
|
144
144
|
'
|
@@ -157,10 +157,12 @@ files:
|
|
157
157
|
- lib/ultravault/config.rb
|
158
158
|
- lib/ultravault/data_objects/agent.rb
|
159
159
|
- lib/ultravault/data_objects/disk_safe.rb
|
160
|
+
- lib/ultravault/data_objects/policy.rb
|
160
161
|
- lib/ultravault/data_objects/recovery_point.rb
|
161
162
|
- lib/ultravault/soap_service.rb
|
162
163
|
- lib/ultravault/soap_service/agent_service.rb
|
163
164
|
- lib/ultravault/soap_service/disk_safe_service.rb
|
165
|
+
- lib/ultravault/soap_service/policy_service.rb
|
164
166
|
- lib/ultravault/soap_service/recovery_point_service.rb
|
165
167
|
- test/all.rb
|
166
168
|
- test/integration/client_code.rb
|
@@ -168,6 +170,7 @@ files:
|
|
168
170
|
- test/support/fixtures/agent_service.rb
|
169
171
|
- test/support/fixtures/disk_safe.rb
|
170
172
|
- test/support/fixtures/disk_safe_service.rb
|
173
|
+
- test/support/fixtures/policy_service.rb
|
171
174
|
- test/support/fixtures/recovery_point_service.rb
|
172
175
|
- test/test_helper.rb
|
173
176
|
- test/unit/lib/ultravault/data_objects/test_agent.rb
|
@@ -175,6 +178,7 @@ files:
|
|
175
178
|
- test/unit/lib/ultravault/data_objects/test_recovery_point.rb
|
176
179
|
- test/unit/lib/ultravault/soap_service/test_agent_service.rb
|
177
180
|
- test/unit/lib/ultravault/soap_service/test_disk_safe_service.rb
|
181
|
+
- test/unit/lib/ultravault/soap_service/test_policy_service.rb
|
178
182
|
- test/unit/lib/ultravault/soap_service/test_recovery_point_service.rb
|
179
183
|
- test/unit/lib/ultravault/test_api_request.rb
|
180
184
|
- test/unit/lib/ultravault/test_client.rb
|
@@ -209,4 +213,3 @@ signing_key:
|
|
209
213
|
specification_version: 3
|
210
214
|
summary: UltraVault
|
211
215
|
test_files: []
|
212
|
-
has_rdoc:
|