icontrol 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,49 @@
1
- = icontrol
1
+ = IControl: F5 BigIP SOAP API Client
2
2
 
3
+ IControl allows you to easily connect to a BigIP F5 load balancer and by means of the SOAP API. You can programmatically do almost the same things that you would do throught the Web Interface.
4
+
5
+ = Installing
6
+
7
+ == Install the gem:
8
+ gem install icontrol
9
+
10
+ = Configuring
11
+
12
+ In order to configure you just have to set up the username, password and the server you're connecting to:
13
+
14
+ IControl.config[:user] = 'username'
15
+ IControl.config[:password] = 'secret'
16
+ IControl.config[:base_url] = "https://myf5.test.com/"
17
+
18
+ = Using the library
19
+
20
+ == Virtual Servers
21
+
22
+ You can retreive, create, delete and modify virtual servers, for more information see IControl::LocalLB::VirtualServer. As an example of you what you can do:
23
+
24
+ === Creating a virtual Server
25
+ new_virtual_server = IControl::LocalLB::VirtualServer.create(:name => "foo_virtual_server",
26
+ :address => "192.168.1.1",
27
+ :port => "80",
28
+ :protocol => IControl::Common::ProtocolType::PROTOCOL_TCP,
29
+ :wildmask => "255.255.255.255",
30
+ :type => IControl::LocalLB::VirtualServer::Type::RESOURCE_TYPE_POOL,
31
+ :default_pool => foo_pool,
32
+ :profiles => [])
33
+
34
+ === Obtaining an instance of a virtual server
35
+
36
+
37
+ my_virtual_server = IControl::LocalLB::VirtualServer.find("virtual_server_name")
38
+
39
+
40
+ === Changing its default pool
41
+
42
+ my_virtual_server.default_pool = IControl::LocalLB::Pool.find("my_new_default_pool")
43
+
44
+ === Destroying it
45
+
46
+ my_virtual_server.destroy
3
47
 
4
48
  == Note on Patches/Pull Requests
5
49
 
@@ -18,10 +18,22 @@ module Attributable
18
18
  end
19
19
 
20
20
  module InstanceMethods
21
+
21
22
  def initialize(attributes)
22
23
  id = attributes.delete(self.class.id_name) if attributes && attributes[self.class.id_name]
23
24
  @attributes = attributes || {}
24
- @attributes[:id] ||= id
25
+ @attributes[:id] ||= id
26
+
27
+ # Now we define an alias for the id_name
28
+ id_name = self.class.id_name
29
+
30
+ (class << self; self; end).instance_eval do
31
+ define_method(id_name) do
32
+ @attributes[:id]
33
+ end
34
+ end if id_name
35
+
36
+
25
37
  end
26
38
 
27
39
  def method_missing(method_name,*args,&block)
@@ -2,6 +2,7 @@
2
2
  require 'savon'
3
3
  require 'net/https'
4
4
  require 'digest/md5'
5
+ Savon::Request.log = false
5
6
 
6
7
  # The idea is to create an object proxy to the web service client with the same structure
7
8
  # than the IControl stuff
@@ -92,7 +93,7 @@ module IControl
92
93
  @config = {
93
94
  :user => "", # username and password
94
95
  :password => "",
95
- :base_url => "", # base url for the web-service (https://example.com/iControl/iControlPortal.cgi)
96
+ :base_url => "", # base url for the web-service (https://example.com/)
96
97
  :test_mode => false, # When test mode is set, the soap responses are saved (this is done to ease the testing fixtures generation)
97
98
  :test_path => File.join(File.dirname(__FILE__),"..","..","spec","fixtures"),
98
99
  :test_file_prefix => ""
@@ -146,7 +147,7 @@ module IControl
146
147
  return @client if @client
147
148
  @client = nil
148
149
  if IControl.configured?
149
- @client = Savon::Client.new IControl.config[:base_url] + "?WSDL=#{name.to_s}.#{class_name.to_s}"
150
+ @client = Savon::Client.new IControl.config[:base_url] + "/iControl/iControlPortal.cgi?WSDL=#{name.to_s}.#{class_name.to_s}"
150
151
  @client.request.basic_auth IControl.config[:user],IControl.config[:password]
151
152
  @client.request.http.ssl_client_auth( :verify_mode => OpenSSL::SSL::VERIFY_NONE )
152
153
  else
@@ -5,38 +5,12 @@ module IControl
5
5
  class NoSuchPoolException < Exception; end
6
6
  class MethodNotImplementedException < Exception; end
7
7
 
8
- module ConstDefiner
9
-
10
- def self.included(base)
11
- base.extend(ClassMethods)
12
- end
13
-
14
- module ClassMethods
15
-
16
- def class_name
17
- self.name.split("::").last
18
- end
19
-
20
- def declare_constants(constants,parent)
21
- constants.each do |const_name|
22
- klass = Class.new(parent)
23
- self.const_set(const_name,klass)
24
- end
25
- end
26
-
27
- def from_string(klass)
28
- return eval("::#{self}::#{klass}")
29
- end
30
- end
31
- end
32
-
33
-
34
8
  module Common
35
9
 
36
10
  class VLANFilterList
37
11
  attr_accessor :state,:vlans
38
12
  def initialize(attributes)
39
- @state = IControl::Common::EnabledState.from_string(attributes[:state])
13
+ @state = IControl::Common::EnabledState.const_get(attributes[:state])
40
14
  @vlans = [attributes[:vlans][:item]].flatten.compact
41
15
  end
42
16
 
@@ -72,30 +46,56 @@ module IControl
72
46
  end
73
47
 
74
48
  class SourcePortBehavior
75
- include ConstDefiner
76
- declare_constants [:SOURCE_PORT_PRESERVE,:SOURCE_PORT_PRESERVE_STRICT,:SOURCE_PORT_CHANGE],SourcePortBehavior
49
+ # Attempt to preserve the source port (best effort). This is the default.
50
+ class SOURCE_PORT_PRESERVE ; VALUE = 0; end
51
+ # Preserve source port. Use of the preserve-strict setting should be restricted to UDP only under very special circumstances such as nPath or transparent (that is, no translation of any other L3/L4 field), where there is a 1:1 relationship between virtual IP addresses and node addresses, or when clustered multi-processing (CMP) is disabled.
52
+ class SOURCE_PORT_PRESERVE_STRICT ; VALUE = 1; end
53
+ # The change setting is useful for obfuscating internal network addresses.
54
+ class SOURCE_PORT_CHANGE ; VALUE = 2; end
77
55
  end
78
-
56
+
57
+ ##
58
+ # A list of enabled states.
79
59
  class EnabledState
80
- include ConstDefiner
81
- declare_constants [:STATE_ENABLED,:STATE_DISABLED],EnabledState
60
+ class STATE_DISABLED ; VALUE = 0; end
61
+ class STATE_ENABLED ; VALUE = 1; end
82
62
  end
83
63
 
64
+ ##
65
+ # A list of TMOS modules.
84
66
  class TMOSModule
85
- include ConstDefiner
86
- declare_constants [:TMOS_MODULE_ASM, :TMOS_MODULE_SAM, :TMOS_MODULE_WAM], TMOSModule
67
+ class TMOS_MODULE_SAM ; VALUE = 0; end
68
+ class TMOS_MODULE_ASM ; VALUE = 1; end
69
+ class TMOS_MODULE_WAM ; VALUE = 2; end
87
70
  end
88
71
 
72
+ ##
73
+ # An enumeration of protocol types.
89
74
  class ProtocolType
90
-
91
- include ConstDefiner
92
-
93
- valid_consts = [:PROTOCOL_ANY,:PROTOCOL_IPV6,:PROTOCOL_ROUTING,:PROTOCOL_NONE,
94
- :PROTOCOL_FRAGMENT,:PROTOCOL_DSTOPTS,:PROTOCOL_TCP,:PROTOCOL_UDP,
95
- :PROTOCOL_ICMP,:PROTOCOL_ICMPV6,:PROTOCOL_OSPF,:PROTOCOL_SCTP]
96
-
97
- declare_constants valid_consts,ProtocolType
98
-
75
+ # Protocol is wildcard.
76
+ class PROTOCOL_ANY ; VALUE = 0; end
77
+ # Protocol is IPv6 header.
78
+ class PROTOCOL_IPV6 ; VALUE = 1; end
79
+ # Protocol is IPv6 routing header.
80
+ class PROTOCOL_ROUTING ; VALUE = 2; end
81
+ # Protocol is IPv6 no next header.
82
+ class PROTOCOL_NONE ; VALUE = 3; end
83
+ # Protocol is IPv6 fragmentation header.
84
+ class PROTOCOL_FRAGMENT ; VALUE = 4; end
85
+ # Protocol is IPv6 destination options.
86
+ class PROTOCOL_DSTOPTS ; VALUE = 5; end
87
+ # Protocol is TCP.
88
+ class PROTOCOL_TCP ; VALUE = 6; end
89
+ # Protocol is UDP.
90
+ class PROTOCOL_UDP ; VALUE = 7; end
91
+ # Protocol is ICMP.
92
+ class PROTOCOL_ICMP ; VALUE = 8; end
93
+ # Protocol is ICMPv6.
94
+ class PROTOCOL_ICMPV6 ; VALUE = 9; end
95
+ # Protocol is OSPF.
96
+ class PROTOCOL_OSPF ; VALUE = 10; end
97
+ # Protocol is SCTP.
98
+ class PROTOCOL_SCTP ; VALUE = 11; end
99
99
  end
100
100
 
101
101
  class IPPortDefinition
@@ -1,47 +1,76 @@
1
1
  module IControl
2
2
  module LocalLB
3
3
 
4
+ ##
5
+ # A list of possible levels for hardware acceleration.
4
6
  class HardwareAccelerationMode
5
- include IControl::ConstDefiner
6
- declare_constants [:HW_ACCELERATION_MODE_NONE, :HW_ACCELERATION_ASSIST, :HW_ACCELERATION_MODE_FULL ], HardwareAccelerationMode
7
+ class HW_ACCELERATION_MODE_NONE ; VALUE = 0; end
8
+ class HW_ACCELERATION_MODE_ASSIST; VALUE = 1; end
9
+ class HW_ACCELERATION_MODE_FULL; VALUE = 2 ; end
7
10
  end
8
11
 
12
+ ##
13
+ # An enumeration of clone pool types.
9
14
  class ClonePoolType
10
- include IControl::ConstDefiner
11
- declare_constants [ :CLONE_POOL_TYPE_UNDEFINED, :CLONE_POOL_TYPE_CLIENTSIDE, :CLONE_POOL_TYPE_SERVERSIDE ], ClonePoolType
15
+ class CLONE_POOL_TYPE_UNDEFINED ; VALUE = 0; end
16
+ class CLONE_POOL_TYPE_CLIENTSIDE; VALUE = 1; end
17
+ class CLONE_POOL_TYPE_SERVERSIDE; VALUE = 2 ; end
12
18
  end
13
19
 
20
+ ##
21
+ # A list of profile context types.
14
22
  class ProfileContextType
15
- include IControl::ConstDefiner
16
- declare_constants [ :PROFILE_CONTEXT_TYPE_ALL, :PROFILE_CONTEXT_TYPE_CLIENT, :PROFILE_CONTEXT_TYPE_SERVER], ProfileContextType
23
+ class PROFILE_CONTEXT_TYPE_ALL ; VALUE = 0; end
24
+ class PROFILE_CONTEXT_TYPE_CLIENT; VALUE = 1; end
25
+ class PROFILE_CONTEXT_TYPE_SERVER; VALUE = 2 ; end
17
26
  end
18
-
19
- class SnatType
20
- include IControl::ConstDefiner
21
- declare_constants [ :SNAT_TYPE_NONE, :SNAT_TYPE_TRANSLATION_ADDRESS, :SNAT_TYPE_SNATPOOL, :SNAT_TYPE_AUTOMAP ], SnatType
27
+
28
+ ##
29
+ # A list of translation types.
30
+ class SnatType
31
+ class SNAT_TYPE_NONE ; VALUE = 0; end
32
+ class SNAT_TYPE_TRANSLATION_ADDRESS ; VALUE = 1; end
33
+ class SNAT_TYPE_SNATPOOL ; VALUE = 2; end
34
+ class SNAT_TYPE_AUTOMAP ; VALUE = 3 ; end
22
35
  end
23
36
 
37
+ ##
38
+ # A list of profile types.
24
39
  class ProfileType
25
- include IControl::ConstDefiner
26
-
27
- declare_constants [ :PROFILE_TYPE_TCP, :PROFILE_TYPE_UDP, :PROFILE_TYPE_FTP, :PROFILE_TYPE_FAST_L4,
28
- :PROFILE_TYPE_HTTP, :PROFILE_TYPE_SERVER_SSL, :PROFILE_TYPE_CLIENT_SSL,
29
- :PROFILE_TYPE_AUTH, :PROFILE_TYPE_PERSISTENCE, :PROFILE_TYPE_CONNECTION_POOL,
30
- :PROFILE_TYPE_STREAM, :PROFILE_TYPE_FAST_HTTP, :PROFILE_TYPE_IIOP,
31
- :PROFILE_TYPE_RTSP, :PROFILE_TYPE_STATISTICS, :PROFILE_TYPE_HTTPCLASS, :PROFILE_TYPE_SCTP,
32
- :PROFILE_TYPE_INSTANCE, :PROFILE_TYPE_SIPP ], ProfileType
40
+ class PROFILE_TYPE_TCP ; VALUE = 0; end
41
+ class PROFILE_TYPE_UDP; VALUE = 1; end
42
+ class PROFILE_TYPE_FTP; VALUE = 2; end
43
+ class PROFILE_TYPE_FAST_L4; VALUE = 3; end
44
+ class PROFILE_TYPE_HTTP; VALUE = 4; end
45
+ class PROFILE_TYPE_SERVER_SSL; VALUE = 5; end
46
+ class PROFILE_TYPE_CLIENT_SSL; VALUE = 6; end
47
+ class PROFILE_TYPE_AUTH; VALUE = 7; end
48
+ class PROFILE_TYPE_PERSISTENCE; VALUE = 8; end
49
+ class PROFILE_TYPE_CONNECTION_POOL; VALUE = 9; end
50
+ class PROFILE_TYPE_STREAM; VALUE = 10; end
51
+ class PROFILE_TYPE_XML; VALUE = 11; end
52
+ class PROFILE_TYPE_FAST_HTTP; VALUE = 12; end
53
+ class PROFILE_TYPE_IIOP; VALUE = 13; end
54
+ class PROFILE_TYPE_RTSP; VALUE = 14; end
55
+ class PROFILE_TYPE_STATISTICS; VALUE = 15; end
56
+ class PROFILE_TYPE_HTTPCLASS; VALUE = 16; end
57
+ class PROFILE_TYPE_DNS; VALUE = 17; end
58
+ class PROFILE_TYPE_SCTP; VALUE = 18; end
59
+ class PROFILE_TYPE_INSTANCE; VALUE = 19; end
60
+ class PROFILE_TYPE_SIPP; VALUE = 20 ; end
33
61
  end
34
62
 
35
- class PersistenceMode
36
- include IControl::ConstDefiner
37
-
38
- declare_constants [ :PERSISTENCE_MODE_NONE, :PERSISTENCE_MODE_SOURCE_ADDRESS_AFFINITY,
39
- :PERSISTENCE_MODE_DESTINATION_ADDRESS_AFFINITY, :PERSISTENCE_MODE_COOKIE,
40
- :PERSISTENCE_MODE_MSRDP, :PERSISTENCE_MODE_SSL_SID, :PERSISTENCE_MODE_SIP,
41
- :PERSISTENCE_MODE_UIE, :PERSISTENCE_MODE_HASH ], PersistenceMode
42
-
43
- end
44
63
 
45
-
64
+ class PersistenceMode
65
+ class PERSISTENCE_MODE_NONE ; VALUE = 0; end
66
+ class PERSISTENCE_MODE_SOURCE_ADDRESS_AFFINITY; VALUE = 1; end
67
+ class PERSISTENCE_MODE_DESTINATION_ADDRESS_AFFINITY; VALUE = 2; end
68
+ class PERSISTENCE_MODE_COOKIE; VALUE = 3; end
69
+ class PERSISTENCE_MODE_MSRDP; VALUE = 4; end
70
+ class PERSISTENCE_MODE_SSL_SID; VALUE = 5; end
71
+ class PERSISTENCE_MODE_SIP; VALUE = 6; end
72
+ class PERSISTENCE_MODE_UIE; VALUE = 7; end
73
+ class PERSISTENCE_MODE_HASH; VALUE = 8 ; end
74
+ end
46
75
  end
47
76
  end
@@ -8,20 +8,34 @@
8
8
  IControl::LocalLB::VirtualServer
9
9
  class IControl::LocalLB::VirtualServer
10
10
 
11
- class Type
12
- include IControl::ConstDefiner
13
- valid_consts = [:RESOURCE_TYPE_POOL,:RESOURCE_TYPE_IP_FORWARDING,:RESOURCE_TYPE_L2_FORWARDING,
14
- :RESOURCE_TYPE_REJECT,:RESOURCE_TYPE_FAST_L4,:RESOURCE_TYPE_FAST_HTTP]
15
-
16
- declare_constants valid_consts,Type
11
+ ##
12
+ # A list of virtual server types.
13
+ module Type
14
+ # The virtual server is based on a pool.
15
+ class RESOURCE_TYPE_POOL ; VALUE = 0; end
16
+ # The virtual server only supports IP forwarding. There is no load balancing on this type of virtual server.
17
+ class RESOURCE_TYPE_IP_FORWARDING ; VALUE = 1; end
18
+ # The virtual server only supports L2 forwarding. There is no load balancing on this type of virtual server.
19
+ class RESOURCE_TYPE_L2_FORWARDING ; VALUE = 2; end
20
+ # All connections going to this virtual server will be rejected, and resets will be sent.
21
+ class RESOURCE_TYPE_REJECT ; VALUE = 3; end
22
+ # The virtual server is based on the Fast L4 profile.
23
+ class RESOURCE_TYPE_FAST_L4 ; VALUE = 4; end
24
+ # The virtual server is based on the Fast HTTP profile.
25
+ class RESOURCE_TYPE_FAST_HTTP ; VALUE = 5; end
17
26
  end
18
27
 
28
+ ##
29
+ # A list of CMP enable modes.
19
30
  class CMPEnableMode
20
- include IControl::ConstDefiner
21
- valid_consts = [:RESOURCE_TYPE_CMP_ENABLE_ALL,:RESOURCE_TYPE_CMP_ENABLE_SINGLE,
22
- :RESOURCE_TYPE_CMP_ENABLE_GROUP,:RESOURCE_TYPE_CMP_ENABLE_UNKNOWN]
23
-
24
- declare_constants valid_consts,CMPEnableMode
31
+ # The virtual server is enabled on all processing cores.
32
+ class RESOURCE_TYPE_CMP_ENABLE_ALL ; VALUE = 0; end
33
+ # The virtual server is enabled on a single processing core.
34
+ class RESOURCE_TYPE_CMP_ENABLE_SINGLE ; VALUE = 1; end
35
+ # The virtual server is enabled on a group of processing cores.
36
+ class RESOURCE_TYPE_CMP_ENABLE_GROUP ; VALUE = 2; end
37
+
38
+ class RESOURCE_TYPE_CMP_ENABLE_UNKNOWN ; VALUE = 3; end
25
39
  end
26
40
 
27
41
  class StatisticEntry
@@ -34,7 +48,7 @@ class IControl::LocalLB::VirtualServer
34
48
  aux.virtual_server = IControl::LocalLB::VirtualServer.find(i[:virtual_server][:name])
35
49
  aux.statistics = {}
36
50
  i[:statistics][:item].each do |entry|
37
- aux.statistics[IControl::Common::StatisticType.from_string(entry[:type])] = IControl::Common::ULong64.new(entry[:value])
51
+ aux.statistics[IControl::Common::StatisticType.const_get(entry[:type])] = IControl::Common::ULong64.new(entry[:value])
38
52
  end
39
53
  aux
40
54
  end
@@ -46,7 +60,7 @@ class IControl::LocalLB::VirtualServer
46
60
  attr_accessor :tmos_module ,:score
47
61
  def initialize(attribules)
48
62
  @score = attributes[:score]
49
- @tmos_module = IControl::Common::TMOSModule.from_string(attributes[:tmos_module])
63
+ @tmos_module = IControl::Common::TMOSModule.const_get(attributes[:tmos_module])
50
64
  end
51
65
  end
52
66
  =begin
@@ -63,7 +77,7 @@ class IControl::LocalLB::VirtualServer
63
77
  attr_accessor :pool,:clone_type
64
78
  def initialize(attributes)
65
79
  @pool = IControl::LocalLB::Pool.find(attributes[:pool_name])
66
- @clone_type = IControl::LocalLB::ClonePoolType.from_string(attributes[:type])
80
+ @clone_type = IControl::LocalLB::ClonePoolType.const_get(attributes[:type])
67
81
  end
68
82
  end
69
83
 
@@ -149,7 +163,7 @@ class IControl::LocalLB::VirtualServer
149
163
 
150
164
  attributes[:profiles].each do |i|
151
165
  if i.class == Hash
152
- profiles["item#{item+=1}"] = {"profile_context" => i["profile_context"].class_name,"profile_name" => ( i["profile"] ? i["profile"] : "tcp" ) }
166
+ profiles["item#{item+=1}"] = {"profile_context" => i["profile_context"].name.split("::").last,"profile_name" => ( i["profile"] ? i["profile"] : "tcp" ) }
153
167
  else
154
168
  profiles["item#{item+=1}"] = {"profile_context" => i.profile_context,"profile_name" => i.profile_name || "tcp" }
155
169
  end
@@ -160,12 +174,12 @@ class IControl::LocalLB::VirtualServer
160
174
  :name => attributes[:name],
161
175
  :address => attributes[:address],
162
176
  "port" => attributes[:port],
163
- :protocol => (attributes[:protocol] || IControl::Common::ProtocolType::PROTOCOL_TCP).class_name
177
+ :protocol => (attributes[:protocol] || IControl::Common::ProtocolType::PROTOCOL_TCP).name.split("::").last
164
178
  }
165
179
  },
166
180
  "wildmasks" => {:item => attributes[:wildmask] || "255.255.255.255"},
167
181
  "resources" => {:item => {
168
- :type => (attributes[:type] || IControl::LocalLB::VirtualServer::Type::RESOURCE_TYPE_POOL).class_name,
182
+ :type => (attributes[:type] || IControl::LocalLB::VirtualServer::Type::RESOURCE_TYPE_POOL).name.split("::").last,
169
183
  "default_pool_name" => attributes[:default_pool] ? attributes[:default_pool].id : ""
170
184
  }
171
185
  },
@@ -203,7 +217,7 @@ class IControl::LocalLB::VirtualServer
203
217
  IControl::LocalLB::VirtualServer.set_type do |soap|
204
218
  soap.body = {
205
219
  "virtual_servers" => {:item => id},
206
- "types" => {:item => new_type.class_name}
220
+ "types" => {:item => new_type.name.split("::").last}
207
221
  }
208
222
  end
209
223
  end
@@ -244,12 +258,20 @@ class IControl::LocalLB::VirtualServer
244
258
  super
245
259
  end
246
260
 
261
+ def disable
262
+ self.enabled_state= IControl::Common::EnabledState::STATE_DISABLED
263
+ end
264
+
265
+ def enable
266
+ self.enabled_state= IControl::Common::EnabledState::STATE_ENABLED
267
+ end
268
+
247
269
  # Sets the enabled state of the specified virtual servers.
248
270
  def enabled_state=(state)
249
271
  IControl::LocalLB::VirtualServer.set_enabled_state do |soap|
250
272
  soap.body = {
251
273
  "virtual_servers" => {:item => id},
252
- "states" => {:item => state.class_name}
274
+ "states" => {:item => state.name.split("::").last}
253
275
  }
254
276
  end if state
255
277
  end
@@ -274,7 +296,7 @@ class IControl::LocalLB::VirtualServer
274
296
 
275
297
  def connection_mirror_state=(state)
276
298
  IControl::LocalLB::VirtualServer.set_connection_mirror_state do |soap|
277
- soap.body = {"virtual_servers" => {:item => id},:states => {:item => state.class_name }}
299
+ soap.body = {"virtual_servers" => {:item => id},:states => {:item => state.name.split("::").last }}
278
300
  end
279
301
  end
280
302
 
@@ -286,7 +308,10 @@ class IControl::LocalLB::VirtualServer
286
308
  # Sets the connection limits of the specified virtual server.
287
309
  def connection_limit=(limit)
288
310
  IControl::LocalLB::VirtualServer.set_connection_limit do |soap|
289
- soap.body = {"virtual_servers" => {:item => id},:limits => {:item => IControl::Common::ULong64.new(:low => limit).to_hash}}
311
+ limit = limit.is_a?(IControl::Common::ULong64) ? limit : IControl::Common::ULong64.new(:low => limit)
312
+ soap.body = {
313
+ "virtual_servers" => {:item => id},
314
+ :limits => {:item => limit.to_hash}}
290
315
  end
291
316
  end
292
317
 
@@ -363,6 +388,7 @@ private
363
388
 
364
389
  public
365
390
 
391
+
366
392
  # Gets the lists of VLANs on which access to the specified Virtual Servers are enabled/disabled.
367
393
  def vlan
368
394
  super
@@ -418,10 +444,37 @@ public
418
444
  super
419
445
  end
420
446
 
447
+
448
+ def remove_all_persistence_profiles!
449
+ IControl::LocalLB::VirtualServer.remove_all_persistence_profiles do |soap|
450
+ soap.body = {
451
+ "virtual_servers" => {:item => id }
452
+ }
453
+ end
454
+ end
455
+
421
456
  def persistence_profile=(persistence_profile)
457
+ self.remove_all_persistence_profiles!
422
458
  add_persistence_profile(persistence_profile)
423
459
  end
424
460
 
461
+
462
+ def remove_persistence_profile(persistence_profile)
463
+ IControl::LocalLB::VirtualServer.remove_persistence_profile do |soap|
464
+ soap.body = {
465
+ "virtual_servers" => {:item => id},
466
+ "profiles" => {:item => {:item => {"profile_name" => persistence_profile.profile_name,"default_profile" => persistence_profile.default_profile}}}
467
+ }
468
+ end if persistence_profile && persistence_profile!= ""
469
+ end
470
+
471
+
472
+ def default_persistence_profile=(persistence_profile)
473
+ self.remove_persistence_profile(persistence_profile)
474
+ persistence_profile.default_profile = true
475
+ self.add_persistence_profile(persistence_profile)
476
+ end
477
+
425
478
  def add_persistence_profile(persistence_profile)
426
479
  IControl::LocalLB::VirtualServer.add_persistence_profile do |soap|
427
480
  soap.body = {
@@ -465,7 +518,7 @@ public
465
518
  IControl::LocalLB::VirtualServer.add_rule do |soap|
466
519
  item = "item"; count = 0
467
520
  my_rules = {}
468
- rules.each{ |i| my_rules[item + (count +=1).to_s] = {"rule_name" => i.class == String ? i : i.id, "priority" => count } }
521
+ rules.each{ |i| my_rules[item + (count +=1).to_s] = {"rule_name" => i.class == String ? i : i.rule_name, "priority" => count } }
469
522
  soap.body = {
470
523
  "virtual_servers" => {:item => id},
471
524
  "rules" => {"value" => my_rules }
@@ -524,7 +577,7 @@ public
524
577
  IControl::LocalLB::VirtualServer.set_protocol do |soap|
525
578
  soap.body = {
526
579
  "virtual_servers" => {:item => id},
527
- "protocols" => {:item => protocol.class_name }
580
+ "protocols" => {:item => protocol.name.split("::").last }
528
581
  }
529
582
  end
530
583
  end
@@ -548,11 +601,11 @@ public
548
601
  end
549
602
 
550
603
  def enable_cmp!
551
- cmp_enabled_state = IControl::Common::EnabledState::STATE_ENABLED
604
+ self.cmp_enabled_state = IControl::Common::EnabledState::STATE_ENABLED
552
605
  end
553
606
 
554
607
  def disable_cmp!
555
- cmp_enabled_state = IControl::Common::EnabledState::STATE_DISABLED
608
+ self.cmp_enabled_state = IControl::Common::EnabledState::STATE_DISABLED
556
609
  end
557
610
 
558
611
  # Sets the translate cmp address state receives a EnabledState constant
@@ -572,7 +625,7 @@ public
572
625
  "virtual_servers" => {:item => id},
573
626
  "snatpools" => {:item => snat_pool.id}
574
627
  }
575
- end
628
+ end if snat_pool
576
629
  end
577
630
 
578
631
  def destroy
@@ -588,8 +641,19 @@ public
588
641
  end
589
642
 
590
643
  def vlan=(vlan)
591
- puts "NOT IMPLEMENTED"
592
- raise LocalLB::MethodNotImplementedException
644
+ count=0;
645
+ vlans = {}
646
+ vlan.vlans.each { |i| vlans["item#{count+=1}"]=i}
647
+ IControl::LocalLB::VirtualServer.set_vlan do |soap|
648
+ soap.body = {
649
+ "virtual_servers" => {:item => id},
650
+ "vlans" => { :item =>
651
+ { :state => vlan.state.name.split("::").last,
652
+ :vlans => vlans
653
+ }
654
+ }
655
+ }
656
+ end
593
657
  end
594
658
 
595
659
  =begin