icontrol 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/icontrol/base.rb CHANGED
@@ -61,6 +61,10 @@ module IControl
61
61
  def set_id_name(name)
62
62
  @id_name = name
63
63
  end
64
+
65
+ def mutex
66
+ @mutex ||= Mutex.new
67
+ end
64
68
 
65
69
  def class_name
66
70
  name.split("::").last
@@ -222,11 +226,14 @@ module IControl
222
226
  begin
223
227
  # When calling a soap method we transparently add the ns (I'd rather say we obscurely)
224
228
  request = ""
225
- response = self.client.request(:wsdl, method_name.to_s) do |soap|
226
- soap.namespaces["xmlns:wsdl"] = "urn:iControl:#{parent_modules[1..-1].join(".")}/#{class_name}"
227
- soap.body = convert_to_soap(hash_to_call_args(args.first)) if args.first
228
- block.call(soap) if block
229
- request = soap.to_xml
229
+ response = nil
230
+ mutex.synchronize do
231
+ response = self.client.request(:wsdl, method_name.to_s) do |soap|
232
+ soap.namespaces["xmlns:wsdl"] = "urn:iControl:#{parent_modules[1..-1].join(".")}/#{class_name}"
233
+ soap.body = convert_to_soap(hash_to_call_args(args.first)) if args.first
234
+ block.call(soap) if block
235
+ request = soap.to_xml
236
+ end
230
237
  end
231
238
  return self.map_response(response.to_xml)
232
239
  rescue Savon::HTTP::Error, Savon::SOAP::Fault => error
@@ -1,17 +1,30 @@
1
+ require 'bindata'
1
2
  module IControl
2
3
  module Common
3
4
  class ULong64 < IControl::Base::Struct
5
+
6
+ def from_soap(xml)
7
+ puts "HEY"
8
+ puts xml.inspect
9
+ end
10
+
4
11
  def to_f
5
- retVal = 0.0
6
- if high >=0
7
- retVal = high << 32 & 0xffff0000
12
+ BinData::Uint64be.read(BinData::Int32be.new(high).to_binary_s + BinData::Int32be.new(low).to_binary_s)
13
+ end
14
+
15
+ def to_fd
16
+ retVal = 0.0
17
+ u_high = high.to_s.unpack("L").first || 0
18
+ u_low = low.to_s.unpack("L").first || 0
19
+ if u_high >=0
20
+ retVal = u_high << 32 & 0xffff0000
8
21
  else
9
- retVal = ((high & 0x7fffffff) << 32) + (0x80000000 << 32)
22
+ retVal = ((u_high & 0x7fffffff) << 32) + (0x80000000 << 32)
10
23
  end
11
- if low >=0
12
- retVal += low
24
+ if u_low >=0
25
+ retVal += u_low
13
26
  else
14
- retVal += ((low & 0x7fffffff) + 0x7fffffff)
27
+ retVal += ((u_low & 0x7fffffff) + 0x7fffffff)
15
28
  end
16
29
  return retVal;
17
30
  end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"..",'/spec_helper'))
2
+
3
+ describe IControl::Base do
4
+ use_vcr_cassette "IControl::Base", :record => :all, :match_requests_on => [:uri, :method, :body] # Change :record => :new_episodes when done
5
+ describe "Concurrent invocation" do
6
+ it "should allow to be called concurrently" do
7
+ virtual_servers = []
8
+ pools = []
9
+ threads = []
10
+ lambda {
11
+ 30.times do
12
+ threads << Thread.new do
13
+ virtual_servers << IControl::LocalLB::VirtualServer.find(:all).first
14
+ pools << IControl::LocalLB::Pool.find(:all).first
15
+ end
16
+ end
17
+ threads.each(&:join)
18
+ }.should_not raise_exception
19
+
20
+ virtual_servers.each do |virtual_server|
21
+ virtual_server.id.should == virtual_servers.first.id
22
+ end
23
+ pools.each do |pool|
24
+ pool.id.should == pools.first.id
25
+ end
26
+
27
+ end
28
+ end
29
+
30
+ end
@@ -1,11 +1,16 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),"..",'/spec_helper'))
2
2
 
3
3
  describe IControl::Common::ULong64 do
4
-
4
+ use_vcr_cassette "IControl::Common::ULong64", :record => :all, :match_requests_on => [:uri, :method, :body] # Change :record => :new_episodes when done
5
5
  describe "#to_f" do
6
6
  it "should exist" do
7
7
  IControl::Common::ULong64.new({}).methods.should include(:to_f)
8
8
  end
9
+
10
+ it "should correctly perform the conversion between two unsigned ints and a bignum" do
11
+ IControl::Common::ULong64.new(:high => 0, :low => 37565545).to_f.should == 37565545
12
+ IControl::Common::ULong64.new(:high => 2, :low => -1701380642).to_f.should == 11183521246
13
+ end
9
14
  end
10
15
 
11
16
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 7
9
- version: 0.3.7
8
+ - 8
9
+ version: 0.3.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Fernandez (magec)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-15 00:00:00 +01:00
17
+ date: 2011-03-01 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -48,8 +48,21 @@ dependencies:
48
48
  prerelease: false
49
49
  version_requirements: *id002
50
50
  - !ruby/object:Gem::Dependency
51
- name: vcr
51
+ name: bindata
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
59
+ version: "0"
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: vcr
65
+ requirement: &id004 !ruby/object:Gem::Requirement
53
66
  none: false
54
67
  requirements:
55
68
  - - ~>
@@ -61,10 +74,10 @@ dependencies:
61
74
  version: 1.4.0
62
75
  type: :development
63
76
  prerelease: false
64
- version_requirements: *id003
77
+ version_requirements: *id004
65
78
  - !ruby/object:Gem::Dependency
66
79
  name: webmock
67
- requirement: &id004 !ruby/object:Gem::Requirement
80
+ requirement: &id005 !ruby/object:Gem::Requirement
68
81
  none: false
69
82
  requirements:
70
83
  - - ~>
@@ -75,10 +88,10 @@ dependencies:
75
88
  version: "1.6"
76
89
  type: :development
77
90
  prerelease: false
78
- version_requirements: *id004
91
+ version_requirements: *id005
79
92
  - !ruby/object:Gem::Dependency
80
93
  name: nokogiri
81
- requirement: &id005 !ruby/object:Gem::Requirement
94
+ requirement: &id006 !ruby/object:Gem::Requirement
82
95
  none: false
83
96
  requirements:
84
97
  - - ">="
@@ -88,10 +101,10 @@ dependencies:
88
101
  version: "0"
89
102
  type: :development
90
103
  prerelease: false
91
- version_requirements: *id005
104
+ version_requirements: *id006
92
105
  - !ruby/object:Gem::Dependency
93
106
  name: mechanize
94
- requirement: &id006 !ruby/object:Gem::Requirement
107
+ requirement: &id007 !ruby/object:Gem::Requirement
95
108
  none: false
96
109
  requirements:
97
110
  - - ">="
@@ -101,10 +114,10 @@ dependencies:
101
114
  version: "0"
102
115
  type: :development
103
116
  prerelease: false
104
- version_requirements: *id006
117
+ version_requirements: *id007
105
118
  - !ruby/object:Gem::Dependency
106
119
  name: rspec
107
- requirement: &id007 !ruby/object:Gem::Requirement
120
+ requirement: &id008 !ruby/object:Gem::Requirement
108
121
  none: false
109
122
  requirements:
110
123
  - - ~>
@@ -116,10 +129,10 @@ dependencies:
116
129
  version: 2.3.0
117
130
  type: :development
118
131
  prerelease: false
119
- version_requirements: *id007
132
+ version_requirements: *id008
120
133
  - !ruby/object:Gem::Dependency
121
134
  name: yard
122
- requirement: &id008 !ruby/object:Gem::Requirement
135
+ requirement: &id009 !ruby/object:Gem::Requirement
123
136
  none: false
124
137
  requirements:
125
138
  - - ~>
@@ -131,10 +144,10 @@ dependencies:
131
144
  version: 0.6.0
132
145
  type: :development
133
146
  prerelease: false
134
- version_requirements: *id008
147
+ version_requirements: *id009
135
148
  - !ruby/object:Gem::Dependency
136
149
  name: yard-examples-from-rspec
137
- requirement: &id009 !ruby/object:Gem::Requirement
150
+ requirement: &id010 !ruby/object:Gem::Requirement
138
151
  none: false
139
152
  requirements:
140
153
  - - ~>
@@ -146,10 +159,10 @@ dependencies:
146
159
  version: 0.0.1
147
160
  type: :development
148
161
  prerelease: false
149
- version_requirements: *id009
162
+ version_requirements: *id010
150
163
  - !ruby/object:Gem::Dependency
151
164
  name: bundler
152
- requirement: &id010 !ruby/object:Gem::Requirement
165
+ requirement: &id011 !ruby/object:Gem::Requirement
153
166
  none: false
154
167
  requirements:
155
168
  - - ~>
@@ -161,10 +174,10 @@ dependencies:
161
174
  version: 1.0.0
162
175
  type: :development
163
176
  prerelease: false
164
- version_requirements: *id010
177
+ version_requirements: *id011
165
178
  - !ruby/object:Gem::Dependency
166
179
  name: jeweler
167
- requirement: &id011 !ruby/object:Gem::Requirement
180
+ requirement: &id012 !ruby/object:Gem::Requirement
168
181
  none: false
169
182
  requirements:
170
183
  - - ~>
@@ -176,10 +189,10 @@ dependencies:
176
189
  version: 1.5.2
177
190
  type: :development
178
191
  prerelease: false
179
- version_requirements: *id011
192
+ version_requirements: *id012
180
193
  - !ruby/object:Gem::Dependency
181
194
  name: rcov
182
- requirement: &id012 !ruby/object:Gem::Requirement
195
+ requirement: &id013 !ruby/object:Gem::Requirement
183
196
  none: false
184
197
  requirements:
185
198
  - - ">="
@@ -189,7 +202,7 @@ dependencies:
189
202
  version: "0"
190
203
  type: :development
191
204
  prerelease: false
192
- version_requirements: *id012
205
+ version_requirements: *id013
193
206
  description: This gem allows you to Connect to a F5 appliance by means of its web services
194
207
  email: jfernandezperez@gmail.com
195
208
  executables: []
@@ -362,6 +375,7 @@ files:
362
375
  - README.rdoc
363
376
  - spec/icontrol/base/sequence_spec.rb
364
377
  - spec/icontrol/base/struct_spec.rb
378
+ - spec/icontrol/base_spec.rb
365
379
  - spec/icontrol/common_spec.rb
366
380
  - spec/icontrol/local_lb/pool_member_spec.rb
367
381
  - spec/icontrol/local_lb/pool_spec.rb
@@ -382,7 +396,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
382
396
  requirements:
383
397
  - - ">="
384
398
  - !ruby/object:Gem::Version
385
- hash: -374151087
399
+ hash: -212281297
386
400
  segments:
387
401
  - 0
388
402
  version: "0"
@@ -404,6 +418,7 @@ summary: A ruby client to the BigIP F5
404
418
  test_files:
405
419
  - spec/icontrol/base/sequence_spec.rb
406
420
  - spec/icontrol/base/struct_spec.rb
421
+ - spec/icontrol/base_spec.rb
407
422
  - spec/icontrol/common_spec.rb
408
423
  - spec/icontrol/local_lb/pool_member_spec.rb
409
424
  - spec/icontrol/local_lb/pool_spec.rb