1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-26 06:50:09 +03:00

M #-: Sync Netowrk creation state in provision

(cherry picked from commit 1c14168f5fe8dcd1f1afc5f46f5b2d84234d0ef6)
This commit is contained in:
Ruben S. Montero 2022-05-05 12:44:26 +02:00
parent 488fd440ac
commit 7a4b8257c1
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 41 additions and 1 deletions

View File

@ -138,6 +138,28 @@ module OpenNebula::WaitExt
# Wait classes and the name published in ZMQ/STATE
WAIT = {
OpenNebula::VirtualNetwork => {
:event => lambda {|o, s1, _s2|
"EVENT STATE NET/#{s1}//#{o['ID']}"
},
:in_state => lambda {|o, s1, _s2|
obj_s = Integer(o['STATE'])
inx_s = OpenNebula::VirtualNetwork::VN_STATES.index(s1)
obj_s == inx_s
},
:in_state_e => lambda {|s1, _s2, content|
xml = Nokogiri::XML(Base64.decode64(content))
obj_s = Integer(xml.xpath('//VNET/STATE').text)
inx_s = OpenNebula::VirtualNetwork::VN_STATES.index(s1)
obj_s == inx_s
}
},
OpenNebula::Host => {
:event => lambda {|o, s1, _s2|
"EVENT STATE HOST/#{s1}//#{o['ID']}"

View File

@ -44,7 +44,25 @@ module OneProvision
end
end
super
net_id = super
vnet = OpenNebula::VirtualNetwork.new_with_id(net_id, @client)
require 'opennebula/wait_ext'
vnet.extend(OpenNebula::WaitExt)
rc = vnet.wait('READY', 300, 2)
if !rc && vnet.state_str == 'ERROR'
vnet.delete
Utils.exception(OpenNebula::Error.new('Error creating network'))
elsif !rc
OneProvisionLogger.warn('Network not READY, '\
'check status after provision completes')
end
net_id
end
# Info an specific object