Sha256: bee4fc5dff86a04d18351b280a6633b633e6e86440c4af6325240d6d4f2f3b88

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module Kakine
  class Director
    class << self
      def show_current_security_group
        puts Kakine::Builder.security_groups
      end

      def apply
        current_sgs = Kakine::Resource.get(:openstack).load_security_group
        new_sgs     = Kakine::Resource.get(:yaml).load_security_group
        new_sgs.each do |new_sg|
          if already_sg = Kakine::Builder.already_setup_security_group(new_sg, current_sgs)
            Kakine::Builder.convergence_security_group(new_sg, already_sg) if new_sg != already_sg
          else
            Kakine::Builder.first_create_security_group(new_sg)
          end
        end

        Kakine::Builder.clean_up_security_group(new_sgs, current_sgs)

      rescue Kakine::Error => e
        puts "[error] #{e}"
      end

      def convert(format, output = nil)
        sgs = Kakine::Resource.get(:yaml).load_security_group

        file = output ? open(output, 'w') : $stdout.dup
        begin
          exporter = Kakine::Exporter.get(format).new(file)
          exporter.export(sgs)
        ensure
          file.close
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kakine-0.7.0 lib/kakine/director.rb
kakine-0.6.5 lib/kakine/director.rb
kakine-0.6.4 lib/kakine/director.rb