[astute] extend_attrs is now different for all depl.modes
This commit is contained in:
parent
e618154a56
commit
0681ba28ca
@ -27,6 +27,6 @@ task_id = `uuidgen`.strip
|
||||
orchestrator = Astute::Orchestrator.new
|
||||
|
||||
|
||||
attrs = {'deployment_mode' => 'simple_compute', 'simple_string' => 'just_string', 'list' => ['a','v'], 'hashes' => [{'a' => '1'}]}
|
||||
attrs = {'deployment_mode' => 'multinode_compute', 'simple_string' => 'just_string', 'list' => ['a','v'], 'hashes' => [{'a' => '1'}]}
|
||||
orchestrator.deploy(reporter, task_id, nodes, attrs)
|
||||
#orchestrator.verify_networks(reporter, task_id, nodes, networks)
|
||||
|
@ -14,22 +14,38 @@ module Astute
|
||||
end
|
||||
|
||||
def deploy(nodes, attrs)
|
||||
# FIXME(mihgen): hardcode simple_compute for now
|
||||
attrs['deployment_mode'] ||= 'simple_compute'
|
||||
attrs['deployment_mode'] ||= 'multinode_compute' # simple multinode deployment is the default
|
||||
Astute.logger.info "Deployment mode #{attrs['deployment_mode']}, using #{self.class} for deployment."
|
||||
result = self.send("deploy_#{attrs['deployment_mode']}", nodes, attrs)
|
||||
attrs_for_mode = self.send("attrs_#{attrs['deployment_mode']}", nodes, attrs)
|
||||
result = self.send("deploy_#{attrs['deployment_mode']}", nodes, attrs_for_mode)
|
||||
end
|
||||
|
||||
def method_missing(method, *args)
|
||||
Astute.logger.error "Method #{method} is not implemented for #{self.class}"
|
||||
end
|
||||
|
||||
# we mix all attrs and prepare them for Puppet
|
||||
# Works for multinode_compute deployment mode
|
||||
def attrs_multinode_compute(nodes, attrs)
|
||||
ctrl_nodes = nodes.select {|n| n['role'] == 'controller'}
|
||||
# TODO(mihgen): we should report error back if there are not enough metadata passed
|
||||
ctrl_management_ips = []
|
||||
ctrl_public_ips = []
|
||||
ctrl_nodes.each do |n|
|
||||
ctrl_management_ips << n['network_data'].select {|nd| nd['name'] == 'management'}[0]['ip']
|
||||
ctrl_public_ips << n['network_data'].select {|nd| nd['name'] == 'public'}[0]['ip']
|
||||
end
|
||||
|
||||
attrs['controller_node_address'] = ctrl_management_ips[0].split('/')[0]
|
||||
attrs['controller_node_public'] = ctrl_public_ips[0].split('/')[0]
|
||||
attrs
|
||||
end
|
||||
|
||||
# This method is called by Ruby metaprogramming magic from deploy method
|
||||
# It should not contain any magic with attributes, and should not directly run any type of MC plugins
|
||||
# It does only support of deployment sequence. See deploy_piece implementation in subclasses.
|
||||
def deploy_simple_compute(nodes, attrs)
|
||||
def deploy_multinode_compute(nodes, attrs)
|
||||
ctrl_nodes = nodes.select {|n| n['role'] == 'controller'}
|
||||
attrs = extend_attrs(nodes, attrs)
|
||||
Astute.logger.info "Starting deployment of controllers"
|
||||
deploy_piece(ctrl_nodes, attrs)
|
||||
|
||||
@ -50,11 +66,6 @@ module Astute
|
||||
{'nodes' => nodes.map { |n| {'uid' => n['uid'], 'status' => status} }}
|
||||
end
|
||||
|
||||
def extend_attrs(nodes, attrs)
|
||||
# See overrides in subclasses
|
||||
attrs
|
||||
end
|
||||
|
||||
def validate_nodes(nodes)
|
||||
if nodes.empty?
|
||||
Astute.logger.info "#{@ctx.task_id}: Nodes to deploy are not provided. Do nothing."
|
||||
|
@ -1,23 +1,5 @@
|
||||
class Astute::DeploymentEngine::NailyFact < Astute::DeploymentEngine
|
||||
|
||||
# This is the main method where we mix all attrs and prepare them for Puppet
|
||||
# It's called from superclass's main deployment method
|
||||
def extend_attrs(nodes, attrs)
|
||||
ctrl_nodes = nodes.select {|n| n['role'] == 'controller'}
|
||||
# TODO(mihgen): we should report error back if there are not enough metadata passed
|
||||
ctrl_management_ips = []
|
||||
ctrl_public_ips = []
|
||||
ctrl_nodes.each do |n|
|
||||
ctrl_management_ips << n['network_data'].select {|nd| nd['name'] == 'management'}[0]['ip']
|
||||
ctrl_public_ips << n['network_data'].select {|nd| nd['name'] == 'public'}[0]['ip']
|
||||
end
|
||||
|
||||
# TODO(mihgen): we take first IP, is it Ok for all installations? I suppose it would not be for HA..
|
||||
attrs['controller_node_address'] = ctrl_management_ips[0].split('/')[0]
|
||||
attrs['controller_node_public'] = ctrl_public_ips[0].split('/')[0]
|
||||
attrs
|
||||
end
|
||||
|
||||
def create_facts(node, attrs)
|
||||
metapublisher = Astute::Metadata.method(:publish_facts)
|
||||
# calculate_networks method is common and you can find it in superclass
|
||||
|
@ -4,7 +4,7 @@ metadata :name => "Naily Fact Agent",
|
||||
:license => "GPL",
|
||||
:version => "Version 1",
|
||||
:url => "www.naily.com",
|
||||
:timeout => 30
|
||||
:timeout => 40
|
||||
|
||||
action "get", :description => "fetches a value from a file" do
|
||||
display :failed
|
||||
|
Loading…
Reference in New Issue
Block a user