Class: Elasticsnap::SecurityGroup
- Inherits:
-
Object
- Object
- Elasticsnap::SecurityGroup
- Defined in:
- lib/elasticsnap/security_group.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #fog_group ⇒ Object
- #hosts ⇒ Object
- #id ⇒ Object
-
#initialize(name: nil) ⇒ SecurityGroup
constructor
A new instance of SecurityGroup.
- #reload ⇒ Object
- #ssh_hosts(ssh_user: nil) ⇒ Object
- #volumes(cluster_name: nil) ⇒ Object
Constructor Details
#initialize(name: nil) ⇒ SecurityGroup
Returns a new instance of SecurityGroup.
7 8 9 10 11 |
# File 'lib/elasticsnap/security_group.rb', line 7 def initialize(name: nil) raise ArgumentError, 'name required' if name.nil? @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/elasticsnap/security_group.rb', line 5 def name @name end |
Instance Method Details
#fog_group ⇒ Object
33 34 35 |
# File 'lib/elasticsnap/security_group.rb', line 33 def fog_group @fog_group ||= connection.security_groups.all('group-name' => name).first end |
#hosts ⇒ Object
13 14 15 |
# File 'lib/elasticsnap/security_group.rb', line 13 def hosts @hosts ||= connection.servers.all('group-id' => id) end |
#id ⇒ Object
37 38 39 |
# File 'lib/elasticsnap/security_group.rb', line 37 def id @id ||= fog_group.group_id end |
#reload ⇒ Object
41 42 43 |
# File 'lib/elasticsnap/security_group.rb', line 41 def reload @hosts = @id = nil end |
#ssh_hosts(ssh_user: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/elasticsnap/security_group.rb', line 17 def ssh_hosts(ssh_user: nil) hosts.map do |host| if ssh_user "#{ssh_user}@#{host.dns_name}" else host.dns_name end end end |
#volumes(cluster_name: nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/elasticsnap/security_group.rb', line 27 def volumes(cluster_name: nil) filters = { 'attachment.instance-id' => hosts.map(&:id) } filters.merge!('tag:ClusterName' => cluster_name) if cluster_name connection.volumes.all(filters) end |