| 
									
										
										
										
											2015-10-26 17:14:48 +03:00
										 |  |  | require_relative "accounts_factory" | 
					
						
							|  |  |  | module Provider | 
					
						
							|  |  |  |   class StaticAccountsFactory < AccountsFactory | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-01 16:04:53 +03:00
										 |  |  |     def init config | 
					
						
							|  |  |  |       @connections = {} | 
					
						
							|  |  |  |       accounts.each do |account| | 
					
						
							|  |  |  |         create_connection_from_account(config, account) | 
					
						
							|  |  |  |         puts "\tFound static account '#{account.account_name}'" | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |       ProviderFactory.add_provider Static::PROVIDER unless @connections.empty? | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def provider_name | 
					
						
							|  |  |  |       Static::PROVIDER | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_connection_from_account config, account | 
					
						
							|  |  |  |        options = { | 
					
						
							|  |  |  |         static_ssh_key: account.ssh_key, | 
					
						
							|  |  |  |         mongo_db: config[:mongo_db], | 
					
						
							|  |  |  |         mongo_host: config[:mongo_host], | 
					
						
							|  |  |  |         mongo_port: config[:mongo_port], | 
					
						
							|  |  |  |         mongo_user: config[:mongo_user], | 
					
						
							|  |  |  |         mongo_password: config[:mongo_password] | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       add_connection(account.account_name, Static.new(options)) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_account hash | 
					
						
							|  |  |  |       Devops::Model::StaticProviderAccount.new(hash) | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-26 17:14:48 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |