| 
									
										
										
										
											2014-11-27 18:45:35 +03:00
										 |  |  | module Validators | 
					
						
							|  |  |  |   class DeployEnv::Groups < Base | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def valid? | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  |       return true if @model.groups.nil? | 
					
						
							|  |  |  |       @invalid_groups = @model.groups - available_groups | 
					
						
							| 
									
										
										
										
											2014-11-27 18:45:35 +03:00
										 |  |  |       @invalid_groups.empty? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def message | 
					
						
							| 
									
										
										
										
											2014-11-28 15:12:07 +03:00
										 |  |  |       "Invalid groups '#{@invalid_groups.join("', '")}'." | 
					
						
							| 
									
										
										
										
											2014-11-27 18:45:35 +03:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2015-11-03 11:46:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def available_groups | 
					
						
							|  |  |  |       subnets_filter = @model.subnets_filter | 
					
						
							|  |  |  |       @model.provider_instance.groups(subnets_filter).keys | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2014-11-27 18:45:35 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |