Class: Haas::Blueprints
- Inherits:
-
Object
- Object
- Haas::Blueprints
- Defined in:
- lib/haas/blueprints.rb
Class Method Summary collapse
- .get_blueprint ⇒ Object
- .get_cluster ⇒ Object
- .post_blueprints ⇒ Object
- .post_json(host, port, url, params) ⇒ Object
Class Method Details
.get_blueprint ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/haas/blueprints.rb', line 29 def self.get_blueprint { "configurations" => [ { "hive-site"=> { "javax.jdo.option.ConnectionPassword"=> "hive" } }, { "nagios-env" => { "nagios_contact" => "admin@localhost" } } ], "host_groups" => [ { "name" => "master", "components" => [ { "name" => "NAMENODE" }, { "name" => "SECONDARY_NAMENODE" }, { "name" => "RESOURCEMANAGER" }, { "name" => "HISTORYSERVER" }, { "name" => "NAGIOS_SERVER" }, { "name" => "GANGLIA_SERVER" }, { "name" => "ZOOKEEPER_SERVER" }, { "name" => "GANGLIA_MONITOR" }, { "name" => "APP_TIMELINE_SERVER" } ], "cardinality" => "1" }, { "name" => "slaves", "components" => [ { "name" => "DATANODE" }, { "name" => "HDFS_CLIENT" }, { "name" => "NODEMANAGER" }, { "name" => "YARN_CLIENT" }, { "name" => "MAPREDUCE2_CLIENT" }, { "name" => "ZOOKEEPER_CLIENT" }, { "name" => "GANGLIA_MONITOR" } ], "cardinality" => "1+" } ], "Blueprints" => { "stack_name" => "HDP", "stack_version" => "2.2" } } end |
.get_cluster ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/haas/blueprints.rb', line 113 def self.get_cluster masters = [] slaves = [] nb_masters = 1 Haas.cluster.nodes.each do |node| if masters.length < nb_masters masters << { "fqdn" => node.private_dns_name } else slaves << { "fqdn" => node.private_dns_name } end end { "blueprint" => "haas-blueprint", "default_password" => "my-super-secret-password", "host_groups" => [ { "name" => "master", "hosts" => masters }, { "name" => "slaves", "hosts" => slaves } ] } end |
.post_blueprints ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/haas/blueprints.rb', line 4 def self.post_blueprints = Haas.cluster. puts "Wait until ambari server is launched" while !Haas::Utils.is_port_open?(.public_dns_name,8080) print '.' sleep 1 end puts ' done.' puts "Wait 20 seconds for the nodes to connect to ambari." sleep 20 puts "Done." post_json(.public_dns_name,8080,'/api/v1/blueprints/haas-blueprint',get_blueprint) post_json(.public_dns_name,8080,'/api/v1/clusters/haas-cluster',get_cluster) end |
.post_json(host, port, url, params) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/haas/blueprints.rb', line 21 def self.post_json(host, port, url, params) req = Net::HTTP::Post.new(url) req.body = params.to_json req.basic_auth("admin", "admin") req["X-Requested-By"] = "HaaS" response = Net::HTTP.new(host, port).start {|http| http.request(req) } end |