Class: VCenterDriver::DsImporter
Overview
Instance Attribute Summary
Attributes inherited from VcImporter
#list
Instance Method Summary
collapse
Methods inherited from VcImporter
#get_indexes, import_clusters, new_child, #one_str, #output, #process_import, register_hooks, #retrieve_resources, sanitize, #stdout
Constructor Details
#initialize(one_client, vi_client) ⇒ DsImporter
Returns a new instance of DsImporter.
875
876
877
878
|
# File 'lib/datastore.rb', line 875
def initialize(one_client, vi_client)
super(one_client, vi_client)
@one_class = OpenNebula::Datastore
end
|
Instance Method Details
#add_cluster(cid, eid) ⇒ Object
912
913
914
915
916
917
|
# File 'lib/datastore.rb', line 912
def add_cluster(cid, eid)
one_cluster = @info[:clusters][cid]
raise 'no cluster defined' unless one_cluster
one_cluster.adddatastore(eid)
end
|
#get_list(_args = {}) ⇒ Object
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
# File 'lib/datastore.rb', line 880
def get_list(_args = {})
dc_folder = VCenterDriver::DatacenterFolder.new(@vi_client)
dpool = VCenterDriver::VIHelper
.one_pool(
OpenNebula::DatastorePool,
false
)
if dpool.respond_to?(:message)
raise "Could not get OpenNebula DatastorePool: #{dpool.message}"
end
hpool = VCenterDriver::VIHelper
.one_pool(
OpenNebula::HostPool,
false
)
if hpool.respond_to?(:message)
raise "Could not get OpenNebula HostPool: #{hpool.message}"
end
rs = dc_folder
.get_unimported_datastores(
dpool,
@vi_client.vc_name,
hpool
)
@list = rs
end
|
#import(selected) ⇒ Object
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
|
# File 'lib/datastore.rb', line 930
def import(selected)
inner = lambda {|object, auth|
one = ''
one << "VCENTER_HOST=\"#{auth[:host]}\"\n"
object.update(one, true)
}
opts = @info[selected[:ref]][:opts]
pair = selected[:ds]
clusters = selected[:cluster]
if opts && opts['selected_clusters']
clusters = opts['selected_clusters'].each.map(&:to_i)
end
res = { :id => [], :name => selected[:simple_name] }
@info[:rollback] = []
pair.each do |ds|
create(ds[:one]) do |one_object, id|
res[:id] << id
add_clusters(id, clusters)
inner.call(
one_object,
@vi_client.host_credentials(
@one_client
)
)
end
end
res
end
|
#remove_default(id) ⇒ Object
919
920
921
922
923
924
925
926
927
928
|
# File 'lib/datastore.rb', line 919
def remove_default(id)
cid = 0
@info[:clusters][cid] ||= VCenterDriver::VIHelper
.one_item(
OpenNebula::Cluster,
cid.to_s,
false
)
@info[:clusters][cid].deldatastore(id.to_i)
end
|