icontrol 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -219,18 +219,26 @@ module IControl
219
219
  # This is done this way cause I need access to name and class_name
220
220
  # metaprogramming to cross the scope, don't really like it actually.
221
221
  # TODO: Make use of the delegation patern much more clean I think
222
-
222
+ # Args are the arguments, bu default every argument is passed as a hash so there should be only 1 element in the args array
223
+ # In certain cases we use a second parameter to pass internal variables (mainly to solve certain cases)
223
224
  def method_missing(method_name,*args,&block)
224
225
  raise IControl::NotConfiguredException unless IControl.configured?
225
- if self.client && self.client.wsdl.operations.keys.include?(method_name)
226
+ current_method_name = ( self.client.wsdl.operations.keys.include?("get_#{method_name}".to_sym ) ) ? "get_#{method_name}".to_sym : method_name
227
+ if self.client && self.client.wsdl.operations.keys.include?(current_method_name)
226
228
  begin
227
229
  # When calling a soap method we transparently add the ns (I'd rather say we obscurely)
228
230
  request = ""
229
231
  response = nil
230
- mutex.synchronize do
231
- response = self.client.request(:wsdl, method_name.to_s) do |soap|
232
+ mutex.synchronize do
233
+ response = self.client.request(:wsdl, current_method_name.to_s) do |soap|
232
234
  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
235
+ if args.first
236
+ if args.first[:raw_call]
237
+ soap.body = convert_to_soap(args.first)
238
+ else
239
+ soap.body = convert_to_soap(hash_to_call_args(args.first))
240
+ end
241
+ end
234
242
  block.call(soap) if block
235
243
  request = soap.to_xml
236
244
  end
@@ -290,7 +298,6 @@ module IControl
290
298
 
291
299
  return super if @attributes.has_key? method_name
292
300
  method_name = "get_#{method_name}" if getters.include? method_name
293
-
294
301
  call_arguments = ( args.first || {} ).merge(default_body)
295
302
 
296
303
  return self.class.send(method_name,call_arguments,&block)
@@ -5,3 +5,4 @@
5
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
6
  require 'icontrol_overlay/local_lb/pool'
7
7
  require 'icontrol_overlay/common'
8
+ require 'icontrol_overlay/management/partition'
@@ -0,0 +1,21 @@
1
+ module IControl::Management
2
+ class Partition < IControl::Base
3
+ def self.find(partition_name)
4
+ partition = [*get_partition_list].flatten.select { |i| i.partition_name == partition_name }.first
5
+ return self.new(:partition_name => partition.partition_name, :description => partition.description) if partition
6
+ end
7
+
8
+ def delete
9
+ return self.class.delete_partition(:partition_names => partition_name)
10
+ end
11
+
12
+ def self.set_active_partition(options)
13
+ options[:raw_call] = true
14
+ return method_missing(:set_active_partition,options)
15
+ end
16
+
17
+ def self.get_list
18
+ get_partition_list
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),"..","..",'/spec_helper'))
2
+
3
+ describe IControl::Management::Partition do
4
+
5
+ use_vcr_cassette "IControl::Management::Partition", :record => :all, :match_requests_on => [:uri, :method, :body] # Change :record => :new_episodes when done
6
+
7
+ describe "active_partition" do
8
+ it "should be called as a class method" do
9
+ lambda {IControl::Management::Partition.active_partition }.should_not raise_exception
10
+ IControl::Management::Partition.active_partition.should == "Common"
11
+ end
12
+ end
13
+
14
+ describe "create_partition" do
15
+ it "should be called as a class method" do
16
+ lambda { IControl::Management::Partition.create_partition(:partition => {:partition_name => "TestPartition",:description => "TestDescription"}) }.should_not raise_exception
17
+ IControl::Management::Partition.find("TestPartition").partition_name.should == "TestPartition"
18
+ end
19
+
20
+ after(:each) do
21
+ IControl::Management::Partition.delete_partition(:partition_name => "TestPartition")
22
+ end
23
+ end
24
+
25
+ describe "#delete" do
26
+ before(:each) do
27
+ IControl::Management::Partition.create_partition(:partition => {:partition_name => "TestPartition",:description => "TestDescription"})
28
+ end
29
+
30
+ it "should delete a given partition" do
31
+ IControl::Management::Partition.find("TestPartition").delete
32
+ end
33
+ end
34
+
35
+ describe ("#set_active_partition") do
36
+ before(:each) do
37
+ IControl::Management::Partition.create_partition(:partition => {:partition_name => "TestPartition",:description => "TestDescription"})
38
+ end
39
+
40
+ it "should set the active partition correctly" do
41
+ active_partition_before = IControl::Management::Partition.active_partition
42
+ IControl::Management::Partition.set_active_partition(:active_partition => "TestPartition")
43
+ active_partition_after = IControl::Management::Partition.active_partition
44
+ active_partition_after.should_not == active_partition_before
45
+ active_partition_after.should_not == ""
46
+ end
47
+
48
+ after(:each) do
49
+ IControl::Management::Partition.set_active_partition(:active_partition => "Common")
50
+ IControl::Management::Partition.find("TestPartition").delete
51
+ end
52
+ end
53
+
54
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 8
9
- version: 0.3.8
8
+ - 9
9
+ version: 0.3.9
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-03-01 00:00:00 +01:00
17
+ date: 2011-03-03 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -240,6 +240,7 @@ files:
240
240
  - lib/icontrol/base/icontrol_overlay.rb
241
241
  - lib/icontrol/base/icontrol_overlay/common.rb
242
242
  - lib/icontrol/base/icontrol_overlay/local_lb/pool.rb
243
+ - lib/icontrol/base/icontrol_overlay/management/partition.rb
243
244
  - lib/icontrol/base/mappings.rb
244
245
  - lib/icontrol/base/predeclarations.rb
245
246
  - lib/icontrol/base/sequence.rb
@@ -381,6 +382,7 @@ files:
381
382
  - spec/icontrol/local_lb/pool_spec.rb
382
383
  - spec/icontrol/local_lb/profile_http_class_spec.rb
383
384
  - spec/icontrol/local_lb/virtual_server_spec.rb
385
+ - spec/icontrol/management/partition_spec.rb
384
386
  - spec/spec_helper.rb
385
387
  has_rdoc: true
386
388
  homepage: http://github.com/magec/icontrol
@@ -396,7 +398,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
396
398
  requirements:
397
399
  - - ">="
398
400
  - !ruby/object:Gem::Version
399
- hash: -212281297
401
+ hash: -394929843
400
402
  segments:
401
403
  - 0
402
404
  version: "0"
@@ -424,4 +426,5 @@ test_files:
424
426
  - spec/icontrol/local_lb/pool_spec.rb
425
427
  - spec/icontrol/local_lb/profile_http_class_spec.rb
426
428
  - spec/icontrol/local_lb/virtual_server_spec.rb
429
+ - spec/icontrol/management/partition_spec.rb
427
430
  - spec/spec_helper.rb