Added check that the metadata proxy successfully deployed
Without this check neutron server on controller nodes tries to start before metadata infrastructure gets initialized from task on primary-controller and terminates with exception. Change-Id: Ifaa559bb849a9b03e6bd4ecd379091302fc27385 Closes-bug: #1587074
This commit is contained in:
parent
33264594a3
commit
0a776f50ef
|
@ -1,6 +1,6 @@
|
|||
notice('fuel-plugin-nsxv: gem-install.pp')
|
||||
|
||||
# ruby gem package must be pre installed before puppet module used
|
||||
package { 'ruby-rbvmomi':
|
||||
package { ['ruby-rbvmomi', 'ruby-rest-client', 'ruby-nokogiri']:
|
||||
ensure => latest,
|
||||
}
|
||||
|
|
|
@ -68,4 +68,18 @@ if 'primary-controller' in hiera('roles') {
|
|||
subscribe => Service['neutron-server'],
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
$settings = hiera($::nsxv::params::plugin_name)
|
||||
$nsxv_ip = $settings['nsxv_manager_host']
|
||||
$nsxv_user = $settings['nsxv_user']
|
||||
$nsxv_password = $settings['nsxv_password']
|
||||
$datacenter_id = $settings['nsxv_datacenter_moid']
|
||||
|
||||
class {'nsxv::neutron_server_check_md_proxy':
|
||||
nsxv_ip => $nsxv_ip,
|
||||
nsxv_user => $nsxv_user,
|
||||
nsxv_password => $nsxv_password,
|
||||
datacenter_id => $datacenter_id,
|
||||
require => [Service['neutron-server'],Exec['waiting-for-neutron-api']],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
#!/usr/bin/env ruby
|
||||
=begin
|
||||
Copyright 2016 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
|
||||
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.
|
||||
|
||||
The script looks for edge with "metadata_proxy_router" in the name and checks
|
||||
its state and edgeStatus. If "state=deployed" and "edgeStatus=green" then
|
||||
return code 0, otherwise 1.
|
||||
=end
|
||||
|
||||
require 'rest-client'
|
||||
require 'nokogiri'
|
||||
|
||||
ip = ARGV[0]
|
||||
user = ARGV[1]
|
||||
pass = ARGV[2]
|
||||
datacenter_id = ARGV[3]
|
||||
|
||||
api_url = 'https://' + ip + '/api/4.0/edges/'
|
||||
list_edges_url = api_url + '?datacenter=' + datacenter_id
|
||||
|
||||
# in worst case this scripts overall timeout is 15 seconds (3 tries * 5 second each try
|
||||
def get_nsxv_api(url, user, pass)
|
||||
retry_count = 3
|
||||
begin
|
||||
response = RestClient::Request.execute(method: :get, url: url, timeout: 15, user: user, password: pass)
|
||||
if response.code == 200
|
||||
xml_response = Nokogiri::XML(response.body)
|
||||
else
|
||||
fail
|
||||
end
|
||||
rescue
|
||||
retry_count -= 1
|
||||
if retry_count > 0
|
||||
sleep 5
|
||||
retry
|
||||
else
|
||||
puts 'Can not get response for request ' + url
|
||||
raise
|
||||
end
|
||||
end
|
||||
return xml_response
|
||||
end
|
||||
|
||||
# list all edges
|
||||
response = get_nsxv_api(list_edges_url, user, pass )
|
||||
response.xpath("//edgeSummary").each do |edge|
|
||||
if /metadata_proxy_router*/i.match(edge.xpath("name").text)
|
||||
if /deployed/i.match(edge.at_xpath("state").text) and /green/i.match(edge.at_xpath("edgeStatus").text)
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
end
|
||||
exit 1
|
|
@ -0,0 +1,21 @@
|
|||
class nsxv::neutron_server_check_md_proxy (
|
||||
$nsxv_ip,
|
||||
$nsxv_user,
|
||||
$nsxv_password,
|
||||
$datacenter_id,
|
||||
) {
|
||||
file { '/tmp/check_md_proxy.rb':
|
||||
ensure => file,
|
||||
mode => '0755',
|
||||
source => "puppet:///modules/${module_name}/check_md_proxy.rb",
|
||||
replace => true,
|
||||
}
|
||||
exec { 'check_md_proxy':
|
||||
tries => '30',
|
||||
try_sleep => '30',
|
||||
command => "/usr/bin/env ruby /tmp/check_md_proxy.rb '${nsxv_ip}' '${nsxv_user}' '${nsxv_password}' '${datacenter_id}'",
|
||||
provider => 'shell',
|
||||
logoutput => on_failure,
|
||||
require => File['/tmp/check_md_proxy.rb'],
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue