1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #5458: onevcenter does not allow to import without a valid cluster, sunstone cache invalidation (#532)

* B #5458: onevcenter does not allow to import resources without a valid cluster

* B #5458: onevcenter does not allow to import nets without a valid cluster

*  B #5458: sunstone gui cache invalidation

(cherry picked from commit a39d1529819a76d8e72bb99de96011a8d8caf1a9)
This commit is contained in:
Sergio Semedi Barranco 2017-10-19 16:16:19 +02:00 committed by Ruben S. Montero
parent 432caf56b4
commit 55a66ae983
3 changed files with 22 additions and 7 deletions

View File

@ -379,6 +379,8 @@ get '/vcenter/networks' do
error 404, error.to_json
end
# clean vcenterDriver cache
VCenterDriver::VIHelper.clean_ref_hash("TEMPLATE/VCENTER_CCR_REF")
networks = dc_folder.get_unimported_networks(npool,vcenter_client.vim.host,hpool)
if networks.nil?
@ -453,6 +455,8 @@ get '/vcenter/datastores' do
error 404, error.to_json
end
# clean vcenterDriver cache
VCenterDriver::VIHelper.clean_ref_hash("TEMPLATE/VCENTER_CCR_REF")
datastores = dc_folder.get_unimported_datastores(dpool, vcenter_client.vim.host, hpool)
if datastores.nil?
msg = "No datacenter found"

View File

@ -644,11 +644,16 @@ def self.import_networks(con_ops, options)
" - Cluster : \e[96m#{n[:cluster]}\e[39m\n"\
" - Cluster location : #{n[:cluster_location]}\n"\
" - OpenNebula Cluster ID : #{n[:one_cluster_id]}\n"
print_str << " Import this Network (y/[n])? "
if n[:one_cluster_id] == -1
print_str << "You need to import the associated vcenter cluster as one host first!"
else
print_str << " Import this Network (y/[n])? "
end
STDOUT.print print_str
next if STDIN.gets.strip.downcase != 'y'
next if STDIN.gets.strip.downcase != 'y' || n[:one_cluster_id] == -1
end
# we try to retrieve once we know the desired net
@ -845,14 +850,20 @@ def self.import_datastore(con_ops, options)
tmps.each{ |d|
if !use_defaults
STDOUT.print "\n * Datastore found:\n"\
datastore_str = "\n * Datastore found:\n"\
" - Name : \e[92m#{d[:simple_name]}\e[39m\n"\
" - Total MB : #{d[:total_mb]}\n"\
" - Free MB : #{d[:free_mb]}\n"\
" - OpenNebula Cluster IDs: #{d[:cluster].join(',')}\n"\
" Import this datastore [y/n]? "
" - OpenNebula Cluster IDs: #{d[:cluster].join(',')}\n"
if d[:cluster].empty?
datastore_str << "You need to import the associated vcenter cluster as one host first!"
else
datastore_str << " Import this datastore [y/n]? "
end
STDOUT.print datastore_str
next if STDIN.gets.strip.downcase != 'y' || d[:cluster].empty?
next if STDIN.gets.strip.downcase != 'y'
STDOUT.print "\n NOTE: For each vCenter datastore a SYSTEM and IMAGE datastore\n"\
" will be created in OpenNebula except for a StorageDRS which is \n"\

View File

@ -75,7 +75,7 @@ class VIHelper
if attr.nil?
@ref_hash = {}
else
@ref_hash[attr] = {}
@ref_hash[attr] = {} unless @ref_hash.nil?
end
end