61 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
		
		
			
		
	
	
			61 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| 
								 | 
							
								require "db/mongo/models/deploy_env/deploy_env_base"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/run_list"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/expiration"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/flavor"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/image"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/subnet_not_empty"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/subnet_belongs_to_provider"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/groups"
							 | 
						||
| 
								 | 
							
								require "db/validators/deploy_env/stack_template"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								module Devops
							 | 
						||
| 
								 | 
							
								  module Model
							 | 
						||
| 
								 | 
							
								    class CloudDeployEnv < DeployEnvBase
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      attr_accessor :flavor, :image, :subnets, :groups, :stack_template
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      types :identifier => {:type => String, :empty => false},
							 | 
						||
| 
								 | 
							
								            :image => {:type => String, :empty => false},
							 | 
						||
| 
								 | 
							
								            :flavor => {:type => String, :empty => false},
							 | 
						||
| 
								 | 
							
								            :provider => {:type => String, :empty => false},
							 | 
						||
| 
								 | 
							
								            :expires => {:type => String, :empty => false, :nil => true},
							 | 
						||
| 
								 | 
							
								            :run_list => {:type => Array, :empty => true},
							 | 
						||
| 
								 | 
							
								            :users => {:type => Array, :empty => true},
							 | 
						||
| 
								 | 
							
								            :subnets => {:type => Array, :empty => true},
							 | 
						||
| 
								 | 
							
								            :groups => {:type => Array, :empty => false},
							 | 
						||
| 
								 | 
							
								            :stack_template => {:type => String, :empty => false, :nil => true}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      set_validators ::Validators::DeployEnv::Flavor,
							 | 
						||
| 
								 | 
							
								                     ::Validators::DeployEnv::Image,
							 | 
						||
| 
								 | 
							
								                     ::Validators::DeployEnv::SubnetNotEmpty,
							 | 
						||
| 
								 | 
							
								                     ::Validators::DeployEnv::SubnetBelongsToProvider,
							 | 
						||
| 
								 | 
							
								                     ::Validators::DeployEnv::Groups,
							 | 
						||
| 
								 | 
							
								                     ::Validators::DeployEnv::StackTemplate
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      def initialize d={}
							 | 
						||
| 
								 | 
							
								        super(d)
							 | 
						||
| 
								 | 
							
								        self.flavor = d["flavor"]
							 | 
						||
| 
								 | 
							
								        self.image = d["image"]
							 | 
						||
| 
								 | 
							
								        self.stack_template = d["stack_template"]
							 | 
						||
| 
								 | 
							
								        b = d["subnets"] || []
							 | 
						||
| 
								 | 
							
								        self.subnets = b.uniq
							 | 
						||
| 
								 | 
							
								        b = d["groups"] || ["default"]
							 | 
						||
| 
								 | 
							
								        self.groups = b.uniq
							 | 
						||
| 
								 | 
							
								      end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								      def to_hash
							 | 
						||
| 
								 | 
							
								        h = super
							 | 
						||
| 
								 | 
							
								        h.merge!({
							 | 
						||
| 
								 | 
							
								          "flavor" => self.flavor,
							 | 
						||
| 
								 | 
							
								          "image" => self.image,
							 | 
						||
| 
								 | 
							
								          "subnets" => self.subnets,
							 | 
						||
| 
								 | 
							
								          "groups" => self.groups,
							 | 
						||
| 
								 | 
							
								          "stack_template" => self.stack_template
							 | 
						||
| 
								 | 
							
								        })
							 | 
						||
| 
								 | 
							
								      end
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    end
							 | 
						||
| 
								 | 
							
								  end
							 | 
						||
| 
								 | 
							
								end
							 | 
						||
| 
								 | 
							
								
							 |