Class: Piculet::EC2Wrapper::SecurityGroupCollection::SecurityGroup
- Inherits:
-
Object
- Object
- Piculet::EC2Wrapper::SecurityGroupCollection::SecurityGroup
show all
- Extended by:
- Forwardable
- Includes:
- Logger::ClientHelper
- Defined in:
- lib/piculet/wrapper/permission.rb,
lib/piculet/wrapper/security-group.rb,
lib/piculet/wrapper/permission-collection.rb
Defined Under Namespace
Classes: PermissionCollection
Instance Method Summary
collapse
#log
Constructor Details
#initialize(security_group, options) ⇒ SecurityGroup
Returns a new instance of SecurityGroup.
12
13
14
15
|
# File 'lib/piculet/wrapper/security-group.rb', line 12
def initialize(security_group, options)
@security_group = security_group
@options = options
end
|
Instance Method Details
#delete ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/piculet/wrapper/security-group.rb', line 32
def delete
log(:info, 'Delete SecurityGroup', :red, "#{vpc_id || :classic} > #{name}")
if name == 'default'
log(:warn, 'SecurityGroup `default` is reserved', :yellow)
else
unless @options.dry_run
@security_group.delete
@options.updated = true
end
end
end
|
#egress_ip_permissions ⇒ Object
59
60
61
|
# File 'lib/piculet/wrapper/security-group.rb', line 59
def egress_ip_permissions
PermissionCollection.new(@security_group, :egress, @options)
end
|
#eql?(dsl) ⇒ Boolean
17
18
19
|
# File 'lib/piculet/wrapper/security-group.rb', line 17
def eql?(dsl)
description_eql?(dsl) and tags_eql?(dsl)
end
|
#ingress_ip_permissions ⇒ Object
55
56
57
|
# File 'lib/piculet/wrapper/security-group.rb', line 55
def ingress_ip_permissions
PermissionCollection.new(@security_group, :ingress, @options)
end
|
49
50
51
52
53
|
# File 'lib/piculet/wrapper/security-group.rb', line 49
def tags
h = {}
@security_group.tags.map {|k, v| h[k] = v }
h
end
|
#update(dsl) ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/piculet/wrapper/security-group.rb', line 21
def update(dsl)
unless description_eql?(dsl)
log(:warn, '`description` cannot be updated', :yellow, "#{vpc_id || :classic} > #{name}")
end
unless tags_eql?(dsl)
log(:info, 'Update SecurityGroup', :green, "#{vpc_id || :classic} > #{name}")
update_tags(dsl)
end
end
|
#vpc? ⇒ Boolean
45
46
47
|
# File 'lib/piculet/wrapper/security-group.rb', line 45
def vpc?
!!@security_group
end
|