Class: HP::Cloud::RuleHelper
- Inherits:
-
BaseHelper
- Object
- BaseHelper
- HP::Cloud::RuleHelper
- Defined in:
- lib/hpcloud/rule_helper.rb
Instance Attribute Summary collapse
-
#cidr ⇒ Object
Returns the value of attribute cidr.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#from ⇒ Object
Returns the value of attribute from.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#source ⇒ Object
Returns the value of attribute source.
-
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
-
#to ⇒ Object
Returns the value of attribute to.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from BaseHelper
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(connection, security_group, foggy = nil) ⇒ RuleHelper
constructor
A new instance of RuleHelper.
- #save ⇒ Object
Methods inherited from BaseHelper
#is_valid?, #set_error, #to_hash
Constructor Details
#initialize(connection, security_group, foggy = nil) ⇒ RuleHelper
Returns a new instance of RuleHelper.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hpcloud/rule_helper.rb', line 32 def initialize(connection, security_group, foggy = nil) super(connection, foggy) @security_group = security_group return if foggy.nil? @id = foggy['id'] @name = foggy['remote_group_id'] @source = @name @protocol = foggy['protocol'] @direction = foggy['direction'] @cidr = foggy['remote_ip_prefix'] @tenant_id = foggy['tenant_id'] @type = foggy['ethertype'] @from = foggy['port_range_min'] @to = foggy['port_range_max'] end |
Instance Attribute Details
#cidr ⇒ Object
Returns the value of attribute cidr.
26 27 28 |
# File 'lib/hpcloud/rule_helper.rb', line 26 def cidr @cidr end |
#direction ⇒ Object
Returns the value of attribute direction.
26 27 28 |
# File 'lib/hpcloud/rule_helper.rb', line 26 def direction @direction end |
#from ⇒ Object
Returns the value of attribute from.
25 26 27 |
# File 'lib/hpcloud/rule_helper.rb', line 25 def from @from end |
#id ⇒ Object
Returns the value of attribute id.
25 26 27 |
# File 'lib/hpcloud/rule_helper.rb', line 25 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/hpcloud/rule_helper.rb', line 25 def name @name end |
#protocol ⇒ Object
Returns the value of attribute protocol.
25 26 27 |
# File 'lib/hpcloud/rule_helper.rb', line 25 def protocol @protocol end |
#source ⇒ Object
Returns the value of attribute source.
25 26 27 |
# File 'lib/hpcloud/rule_helper.rb', line 25 def source @source end |
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
26 27 28 |
# File 'lib/hpcloud/rule_helper.rb', line 26 def tenant_id @tenant_id end |
#to ⇒ Object
Returns the value of attribute to.
25 26 27 |
# File 'lib/hpcloud/rule_helper.rb', line 25 def to @to end |
#type ⇒ Object
Returns the value of attribute type.
26 27 28 |
# File 'lib/hpcloud/rule_helper.rb', line 26 def type @type end |
Class Method Details
.get_keys ⇒ Object
28 29 30 |
# File 'lib/hpcloud/rule_helper.rb', line 28 def self.get_keys() return [ "id", "source", "type", "protocol", "direction", "cidr", "from", "to" ] end |
Instance Method Details
#destroy ⇒ Object
65 66 67 |
# File 'lib/hpcloud/rule_helper.rb', line 65 def destroy @fog.destroy end |
#save ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hpcloud/rule_helper.rb', line 48 def save return false if is_valid? == false if @fog.nil? port_range = @from.to_s + ".." + @to.to_s response = @security_group.fog.create_rule(port_range, @protocol, @name) if response.nil? set_error("Error creating rule") return false end @fog = response.body["security_group_rule"] @id = @fog['id'] return true else raise "Update not implemented" end end |