Multi roles support (+ test). First version without correct log parsing and status report about deploy for the second and followed roles.
This commit is contained in:
parent
28051d8bc3
commit
df0f28c353
|
@ -16,6 +16,18 @@
|
|||
class Astute::DeploymentEngine::NailyFact < Astute::DeploymentEngine
|
||||
|
||||
def deploy(nodes, attrs)
|
||||
# Convert multi roles node to separate one role nodes
|
||||
nodes.each do |node|
|
||||
next unless node['role'].is_a?(Array)
|
||||
|
||||
node['role'].each do |role|
|
||||
new_node = deep_copy(node)
|
||||
new_node['role'] = role
|
||||
nodes << new_node
|
||||
end
|
||||
nodes.delete(node)
|
||||
end
|
||||
|
||||
attrs_for_mode = self.send("attrs_#{attrs['deployment_mode']}", nodes, attrs)
|
||||
super(nodes, attrs_for_mode)
|
||||
end
|
||||
|
@ -81,7 +93,6 @@ class Astute::DeploymentEngine::NailyFact < Astute::DeploymentEngine
|
|||
@ctx.reporter.report(nodes_status(nodes_to_deploy, 'deploying', {'progress' => 0}))
|
||||
|
||||
nodes_to_deploy.each do |node|
|
||||
# Use predefined facts or create new.
|
||||
node['facts'] ||= create_facts(node, attrs)
|
||||
Astute::Metadata.publish_facts(@ctx, node['uid'], node['facts'])
|
||||
end
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
# Copyright 2013 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
module Fixtures
|
||||
|
||||
def self.multiroles_attrs
|
||||
attrs = common_attrs
|
||||
attrs['args']['nodes'] = [
|
||||
{
|
||||
"mac" => "52:54:00:0E:88:88",
|
||||
"status" => "provisioned",
|
||||
"uid" => "4",
|
||||
"error_type" => nil,
|
||||
"fqdn" => "controller_compute-4.mirantis.com",
|
||||
"network_data" => [
|
||||
{
|
||||
"gateway" => "192.168.0.1",
|
||||
"name" => "management",
|
||||
"dev" => "eth0",
|
||||
"brd" => "192.168.0.255",
|
||||
"netmask" => "255.255.255.0",
|
||||
"vlan" => 102,
|
||||
"ip" => "192.168.0.5/24"
|
||||
},
|
||||
{
|
||||
"gateway" => "240.0.1.1",
|
||||
"name" => "public",
|
||||
"dev" => "eth0",
|
||||
"brd" => "240.0.1.255",
|
||||
"netmask" => "255.255.255.0",
|
||||
"vlan" => 101,
|
||||
"ip" => "240.0.1.5/24"
|
||||
},
|
||||
{
|
||||
"name" => "floating",
|
||||
"dev" => "eth0",
|
||||
"vlan" => 120
|
||||
},
|
||||
{
|
||||
"name" => "fixed",
|
||||
"dev" => "eth0",
|
||||
"vlan" => 103
|
||||
},
|
||||
{
|
||||
"name" => "storage",
|
||||
"dev" => "eth0",
|
||||
"vlan" => 104,
|
||||
"ip" => "172.16.1.5/24",
|
||||
"netmask" => "255.255.255.0",
|
||||
"brd" => "172.16.1.255"
|
||||
}
|
||||
],
|
||||
"id" => 4,
|
||||
"ip" => "10.20.0.205",
|
||||
"role" =>
|
||||
[
|
||||
"controller",
|
||||
"compute"
|
||||
],
|
||||
'meta' => meta
|
||||
}
|
||||
]
|
||||
controller_nodes = attrs['args']['nodes'].select{|n| n['role'].include?('controller')}.map { |e| deep_copy e }
|
||||
controller_nodes.each {|n| n['role'] = 'controller' }
|
||||
attrs['args']['controller_nodes'] = controller_nodes
|
||||
attrs
|
||||
end
|
||||
|
||||
end
|
|
@ -28,6 +28,7 @@ describe "NailyFact DeploymentEngine" do
|
|||
|
||||
@data = Fixtures.common_attrs
|
||||
@data_ha = Fixtures.ha_attrs
|
||||
@data_mr = Fixtures.multiroles_attrs
|
||||
end
|
||||
|
||||
it "it should call valid method depends on attrs" do
|
||||
|
@ -58,6 +59,17 @@ describe "NailyFact DeploymentEngine" do
|
|||
Astute::PuppetdDeployer.expects(:deploy).with(@ctx, compute_nodes, instance_of(Fixnum), true).once
|
||||
@deploy_engine.deploy(@data['args']['nodes'], @data['args']['attributes'])
|
||||
end
|
||||
|
||||
it "multiroles for node should be support" do
|
||||
@data_mr['args']['attributes']['deployment_mode'] = "multinode"
|
||||
|
||||
node_amount = @data_mr['args']['nodes'][0]['role'].size
|
||||
# we got two calls, one for controller, and another for all(1) computes
|
||||
Astute::Metadata.expects(:publish_facts).times(node_amount)
|
||||
Astute::PuppetdDeployer.expects(:deploy).times(node_amount)
|
||||
|
||||
@deploy_engine.deploy(@data_mr['args']['nodes'], @data_mr['args']['attributes'])
|
||||
end
|
||||
|
||||
it "ha deploy should not raise any exception" do
|
||||
Astute::Metadata.expects(:publish_facts).at_least_once
|
||||
|
|
Loading…
Reference in New Issue