Class: Weavr::Cluster

Inherits:
Resource show all
Defined in:
lib/weavr/resource/cluster.rb

Instance Method Summary collapse

Methods inherited from Resource

child_resources, #connection, extract_class_params, label, load_definitions!, predefine_class, receive, #receive!, #refresh!, #resource_action

Instance Method Details

#add_components(srvc, names) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/weavr/resource/cluster.rb', line 33

def add_components(srvc, names)
  names.each do |name|
    comp = Component.receive(component_name: name, href: File.join(href, 'services', srvc, 'components', name))
    comp.create
  end
  refresh!
end

#add_hosts(*names) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/weavr/resource/cluster.rb', line 17

def add_hosts(*names)
  names.each do |name|
    host = Host.receive(href: File.join(href, 'hosts', name))
    host.create
  end
  refresh!
end

#add_services(*names) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/weavr/resource/cluster.rb', line 25

def add_services(*names)
  names.each do |name|
    srvc = Service.receive(service_name: name, href: File.join(href, 'services'))
    srvc.create
  end
  refresh!
end

#assign_host_components(mapping) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/weavr/resource/cluster.rb', line 41

def assign_host_components mapping
  mapping.each_pair do |host, comps|
    comps.each do |comp|
      role = HostRole.receive(href: File.join(href, 'hosts', host, 'host_components', comp))
      role.create
    end
  end
end

#create(options) ⇒ Object



12
13
14
15
# File 'lib/weavr/resource/cluster.rb', line 12

def create options
  resource_action(:post, self.class.label => { version: 'HDP-2.1' }.merge(options))
  self
end

#create_config(type, version, properties) ⇒ Object



50
51
52
53
# File 'lib/weavr/resource/cluster.rb', line 50

def create_config(type, version, properties)
  resource_action(:put, self.class.label => { desired_config: { type: type, tag: version, properties: properties } })
  refresh!
end

#deleteObject



55
56
57
# File 'lib/weavr/resource/cluster.rb', line 55

def delete
  resource_action(:delete)
end

#persistObject

Weird persist method for the browser



60
61
62
# File 'lib/weavr/resource/cluster.rb', line 60

def persist
  connection.resource(:post, 'persist', 'CLUSTER_CURRENT_STATUS' => { 'clusterState' => 'CLUSTER_STARTED_5' }.to_json)
end