Class: Dcmgr::Models::SecurityGroup
Constant Summary
Constants inherited
from BaseNew
BaseNew::LOCK_TABLES_KEY
Instance Method Summary
collapse
#account
Methods inherited from BaseNew
Proxy, dataset, default_row_lock_mode=, install_data, install_data_hooks, lock!, unlock!, #with_timestamps?
Instance Method Details
#after_save ⇒ Object
24
25
26
27
|
# File 'lib/dcmgr/models/security_group.rb', line 24
def after_save
super
self.rebuild_rule
end
|
#before_destroy ⇒ Object
33
34
35
36
37
38
|
# File 'lib/dcmgr/models/security_group.rb', line 33
def before_destroy
return false if self.instances.size > 0
self.flush_rule
super
end
|
#build_rule ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/dcmgr/models/security_group.rb', line 46
def build_rule
return if self.rule.nil?
self.rule.split("\n").each { |permission|
next if permission =~ /\A#/
next if permission.length == 0
SecurityGroupRule.create(:security_group_id => self.id,
:permission => permission)
}
end
|
#flush_rule ⇒ Object
29
30
31
|
# File 'lib/dcmgr/models/security_group.rb', line 29
def flush_rule
SecurityGroupRule.filter(:security_group_id => self.id).destroy
end
|
#rebuild_rule ⇒ Object
41
42
43
44
|
# File 'lib/dcmgr/models/security_group.rb', line 41
def rebuild_rule
self.flush_rule
self.build_rule
end
|
#to_api_document ⇒ Object
17
18
19
20
21
22
|
# File 'lib/dcmgr/models/security_group.rb', line 17
def to_api_document
super.merge({
:rule => rule.to_s,
:rules => security_group_rules.map { |rule| rule.to_hash },
})
end
|
#to_hash ⇒ Object
10
11
12
13
14
15
|
# File 'lib/dcmgr/models/security_group.rb', line 10
def to_hash
super.merge({
:rule => rule.to_s,
:rules => security_group_rules.map { |rule| rule.to_hash },
})
end
|