Class: Kanmon::SecurityGroup
- Inherits:
-
Object
- Object
- Kanmon::SecurityGroup
- Defined in:
- lib/kanmon/securitygroup.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(id, port, ip = nil) ⇒ SecurityGroup
constructor
A new instance of SecurityGroup.
- #open ⇒ Object
Constructor Details
#initialize(id, port, ip = nil) ⇒ SecurityGroup
Returns a new instance of SecurityGroup.
9 10 11 12 13 14 |
# File 'lib/kanmon/securitygroup.rb', line 9 def initialize(id, port, ip = nil) @id = id @port = port || 22 @ip = ip || Kanmon::MyIP.get @tenant_id = Yao.current_tenant_id end |
Instance Attribute Details
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
7 8 9 |
# File 'lib/kanmon/securitygroup.rb', line 7 def ip @ip end |
Instance Method Details
#close ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/kanmon/securitygroup.rb', line 29 def close result = Yao::SecurityGroupRule.list(rule) if result.empty? puts "Rule not found" else delete_rules(result) end end |
#open ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kanmon/securitygroup.rb', line 16 def open result = Yao::SecurityGroupRule.create(rule) puts "Added Rule: #{result.id}" if block_given? begin yield ensure delete_rules([result]) end end end |