Class: Haas::Cluster
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Haas::Cluster
- Defined in:
- lib/models/cluster.rb
Instance Method Summary collapse
- #chef_client_pem_path ⇒ Object
- #chef_validator_pem_path ⇒ Object
- #generate_name ⇒ Object
- #get_ambari_server ⇒ Object
- #get_chef_server ⇒ Object
- #identity_file_path ⇒ Object
- #knife_config_path ⇒ Object
- #mkdir_cluster_home ⇒ Object
- #working_dir_path ⇒ Object
Instance Method Details
#chef_client_pem_path ⇒ Object
20 21 22 |
# File 'lib/models/cluster.rb', line 20 def chef_client_pem_path File.join(self.working_dir_path,"haas-api.pem") end |
#chef_validator_pem_path ⇒ Object
24 25 26 |
# File 'lib/models/cluster.rb', line 24 def chef_validator_pem_path File.join(self.working_dir_path,"haas-validator.pem") end |
#generate_name ⇒ Object
32 33 34 35 |
# File 'lib/models/cluster.rb', line 32 def generate_name random_str = (0...8).map { (65 + rand(26)).chr }.join self.name = "HAAS-#{random_str}" end |
#get_ambari_server ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/models/cluster.rb', line 49 def = self.nodes.where('nodes.ambari_server=?',true) if .first return .first else node = self.nodes.where('nodes.chef_server IS NULL').first node. = true node.save return node end end |
#get_chef_server ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/models/cluster.rb', line 37 def get_chef_server chef_server = self.nodes.where('nodes.chef_server=?',true) if chef_server.first return chef_server.first else node = self.nodes.first node.chef_server = true node.save return node end end |
#identity_file_path ⇒ Object
16 17 18 |
# File 'lib/models/cluster.rb', line 16 def identity_file_path File.join(self.working_dir_path,"ssh-#{self.name}.pem") end |
#knife_config_path ⇒ Object
28 29 30 |
# File 'lib/models/cluster.rb', line 28 def knife_config_path File.join(self.working_dir_path,"knife.rb") end |
#mkdir_cluster_home ⇒ Object
7 8 9 10 |
# File 'lib/models/cluster.rb', line 7 def mkdir_cluster_home require 'fileutils' FileUtils.mkdir_p self.working_dir_path end |
#working_dir_path ⇒ Object
12 13 14 |
# File 'lib/models/cluster.rb', line 12 def working_dir_path File.join(Haas::Config::WORKING_DIR, self.name) end |