lib/fog/qingcloud/models/compute/security_group_rule.rb in ns-fog-1.22.7 vs lib/fog/qingcloud/models/compute/security_group_rule.rb in ns-fog-1.22.8
- old
+ new
@@ -13,10 +13,11 @@
attribute :direction
attribute :name, :aliases => 'security_group_rule_name'
attribute :val1
attribute :val2
attribute :val3
+ attribute :auto_apply
def initialize(attrs = {})
if attrs['protocol']
case attrs['protocol'].to_sym
when :tcp, :udp
@@ -25,10 +26,11 @@
attrs['val1'] ||= attrs.delete('icmp_type')
attrs['val2'] ||= attrs.delete('icmp_code')
end
end
attrs['val3'] ||= attrs.delete('src_ip')
+ @auto_apply = attrs.delete('auto_apply') || true
super attrs
end
def save
@@ -38,17 +40,17 @@
modify_attributes(priority, name)
else
requires :protocol, :priority
self.id = service.add_security_group_rules(group_id, to_query).body['security_group_rules'].first
end
- service.apply_security_group(group_id)
+ service.apply_security_group(group_id) if @auto_apply
true
end
def destroy
requires :id
service.delete_security_group_rules(id)
- service.apply_security_group(group_id)
+ service.apply_security_group(group_id) if @auto_apply
true
end
def modify_attributes(priority, name = nil)
requires :id, :priority