Sha256: 0aa2b34d7486631bf7a660a38c6ce95e9277ab4eb5055db73e8898d4776962c9
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module Kakine class CLI < Thor class Operation def set_adapter(adapter) @adapter = adapter end def create_security_group(sg) attributes = {name: sg.name, description: sg.description, tenant_id: sg.tenant_id} security_group_id = @adapter.create_security_group(attributes) #delete default rule delete_sg = sg.clone delete_sg.set_default_rules delete_security_rule(delete_sg) unless @adapter.instance_of?(Kakine::Adapter::Mock) security_group_id end def delete_security_group(sg) security_group = Kakine::Resource.security_group(sg.tenant_name, sg.name) @adapter.delete_security_group(security_group.id) end def create_security_rule(sg, security_group_id=nil) if security_group_id.nil? security_group = Kakine::Resource.security_group(sg.tenant_name, sg.name) security_group_id = security_group.id end sg.rules.each do |rule| @adapter.create_rule(security_group_id, rule["direction"], rule) end if sg.has_rules? end def delete_security_rule(sg) security_group = Kakine::Resource.security_group(sg.tenant_name, sg.name) sg.rules.each do |rule| security_group_rule = Kakine::Resource.security_group_rule(security_group, rule) @adapter.delete_rule(security_group_rule.id) end if sg.has_rules? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kakine-0.2.0 | lib/kakine/cli/operation.rb |