module Devops
  module ProjectType

    class << self
      @@types = {}
      def included mod
        @@types[mod.name] = mod
        puts "Project type '#{mod.name}' registered"
      end

      def types
        @@types
      end
    end

    def prepare project

    end

    def extract_servers project, env, params
=begin
      mongo = ::Devops::Db.connector
      env_name = env.identifier
      project_name = project.id
      servers_info = []
      i = mongo.image env.image
      rl = Set.new
      rl.merge(project.run_list).merge(env.run_list)
      o = {
        :image => i,
        :name => ,
        :flavor => flavor["id"],
        :groups => params["groups"] || env.groups,
        :run_list => rl,
        :subnets => env.subnets,
        :key =>
      }
      servers_info.push(o)

      servers = []
      servers_info.each do |info|
        servers.push s
      end
      return servers

        image = info[:image]
=end
        s = Devops::Model::Server.new
        s.provider = provider.name
        s.project = project_name
        s.deploy_env = env_name
        s.run_list = params["run_list"] || []
        s.remote_user = image.remote_user
        s.name = params["name"]
        s.key = params["key"] || provider.ssh_key
=begin
        s.options = {
          :image => image.id,
          :flavor => info[:flavor],
          :name => info[:name],
          :groups => info[:groups],
          :run_list => info[:run_list].merge(s.run_list),
          :bootstrap_template => image.bootstrap_template,
          :subnets => info[:subnets]
        }
=end
        #s.created_by = user
      [s]
    end
  end
end
