Class: Haas

Inherits:
Object
  • Object
show all
Defined in:
lib/haas.rb,
lib/haas/aws.rb,
lib/haas/chef.rb,
lib/haas/utils.rb,
lib/haas/config.rb,
lib/models/node.rb,
lib/models/cluster.rb,
lib/haas/blueprints.rb,
lib/models/key_pair.rb

Defined Under Namespace

Classes: Aws, Blueprints, ChefProvider, Cluster, Config, KeyPair, Node, Utils

Class Method Summary collapse

Class Method Details

.clusterObject



61
62
63
# File 'lib/haas.rb', line 61

def self.cluster
  return @cluster
end

.launchObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/haas.rb', line 12

def self.launch
  Haas::Aws.connect
  @cluster=Haas::Cluster.create(
    :aws_region => Haas::Aws.region,
    :ssh_user => Haas::Aws.ssh_user,
    :distro => "ubuntu12"
  )
  if Haas::Aws.nb_instance_available >= Haas::Config.options[:nb_instances].to_i
    Haas::Aws.create_key_pair
    Haas::Aws.launch_instances
  else
    puts "There is not enough instances available.\nYou can request a limit increase here : https://aws.amazon.com/support/createCase?serviceLimitIncreaseType=ec2-instances&type=service_limit_increase"
    exit
  end

  Haas::ChefProvider.setup_cluster
  Haas::Blueprints.post_blueprints

  puts "\n"
  puts "=========== installation report =============="
  puts "Ambari is finalizing the installation"
  puts "You can access Ambari to manage your cluster at the following address:"
  puts "http://#{@cluster.get_ambari_server.public_dns_name}:8080/"
  puts "user: admin"
  puts "password: admin"
  puts "\n"
  puts "Nodes of the cluster:"
  @cluster.nodes.each do |node|
    puts "    #{node.public_dns_name}"
  end
  puts "\n"
  puts "You can use this SSH key to log into each node as user #{@cluster.ssh_user}"
  puts @cluster.identity_file_path
end

.set_cluster(cluster) ⇒ Object



65
66
67
# File 'lib/haas.rb', line 65

def self.set_cluster cluster
  @cluster = cluster
end

.showObject



47
48
49
50
51
52
53
54
# File 'lib/haas.rb', line 47

def self.show
  Haas::Cluster.all.each do |cluster|
    puts "Cluster - #{cluster.name}"
    cluster.nodes.each do |node|
      puts "        #{node.instance_id} - #{node.ip_address} - #{node.private_ip_address}"
    end
  end
end

.terminate(cluster_name) ⇒ Object



56
57
58
59
# File 'lib/haas.rb', line 56

def self.terminate cluster_name
  Haas::Aws.connect
  Haas::Aws.terminate_cluster Cluster.first
end