mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
F #4913: Remove VCENTER_ONE_HOST_ID from datastore actions and required attrs
This commit is contained in:
parent
2f5a3185df
commit
bb36e6c448
@ -988,7 +988,7 @@ DS_MAD_CONF = [
|
||||
|
||||
DS_MAD_CONF = [
|
||||
NAME = "vcenter",
|
||||
REQUIRED_ATTRS = "VCENTER_ONE_HOST_ID, VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_CCR_REF",
|
||||
REQUIRED_ATTRS = "VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_DC_REF, VCENTER_HOST, VCENTER_USER, VCENTER_PASSWORD",
|
||||
PERSISTENT_ONLY = "YES",
|
||||
MARKETPLACE_ACTIONS = "export"
|
||||
]
|
||||
|
@ -1136,7 +1136,7 @@ DS_MAD_CONF = [
|
||||
|
||||
DS_MAD_CONF = [
|
||||
NAME = "vcenter",
|
||||
REQUIRED_ATTRS = "VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_DC_REF",
|
||||
REQUIRED_ATTRS = "VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_DC_REF, VCENTER_HOST, VCENTER_USER, VCENTER_PASSWORD",
|
||||
PERSISTENT_ONLY = "NO",
|
||||
MARKETPLACE_ACTIONS = "export"
|
||||
]
|
||||
|
@ -36,13 +36,11 @@ drv_action = OpenNebula::XMLElement.new
|
||||
drv_action.initialize_xml(Base64.decode64(drv_action_enc), 'DS_DRIVER_ACTION_DATA')
|
||||
|
||||
target_ds_ref = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_REF"]
|
||||
##host_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
|
||||
ds_image_dir = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_IMAGE_DIR"] || "one"
|
||||
src_path = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/PATH"]
|
||||
src_img_id = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/CLONING_ID"]
|
||||
|
||||
check_valid src_img_id, "cloning id"
|
||||
##check_valid host_id, "vcenter cluster"
|
||||
check_valid src_path, "image path"
|
||||
check_valid target_ds_ref, "target ds ref"
|
||||
|
||||
@ -56,7 +54,6 @@ source_ds_ref = source_ds['TEMPLATE/VCENTER_DS_REF']
|
||||
target_path = "#{ds_image_dir}/#{id}/one-#{id}.vmdk"
|
||||
|
||||
begin
|
||||
##vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(source_ds_id)
|
||||
|
||||
|
@ -45,9 +45,7 @@ md5 = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5"]
|
||||
|
||||
md5 = md5.nil? ? "-" : md5
|
||||
|
||||
hostname = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
|
||||
ds_name = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/NAME"]
|
||||
|
||||
ds_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/ID"]
|
||||
|
||||
if img_source.nil?
|
||||
message = "Not enough information to export the image,"\
|
||||
@ -60,8 +58,7 @@ end
|
||||
# the vCenter datastore
|
||||
|
||||
vcenter_url_img = "vcenter://#{img_source}?"\
|
||||
"param_dsname=#{ds_name}&"\
|
||||
"param_host=#{hostname}"
|
||||
"param_dsid=#{ds_id}"
|
||||
|
||||
# Create import info document for marketplace import script
|
||||
|
||||
|
@ -41,7 +41,6 @@ drv_action.initialize_xml(Base64.decode64(drv_action_enc), 'DS_DRIVER_ACTION_DAT
|
||||
|
||||
ds_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/ID"]
|
||||
ds_ref = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_REF"]
|
||||
##host_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
|
||||
ds_image_dir = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_IMAGE_DIR"] || "one"
|
||||
img_id = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/ID"]
|
||||
adapter_type = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/VCENTER_ADAPTER_TYPE"] ||
|
||||
@ -52,7 +51,6 @@ size = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/SIZE"]
|
||||
fs_type = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE"]
|
||||
|
||||
check_valid img_id, "img_id"
|
||||
##check_valid host_id, "vcenter_cluster"
|
||||
check_valid adapter_type, "adapter_type"
|
||||
check_valid disk_type, "disk_type"
|
||||
check_valid size, "size"
|
||||
@ -68,7 +66,6 @@ if fs_type == "save_as"
|
||||
end
|
||||
|
||||
begin
|
||||
##vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(ds_id)
|
||||
|
||||
ds = VCenterDriver::Datastore.new_from_ref(ds_ref, vi_client)
|
||||
|
@ -39,19 +39,16 @@ id = ARGV[1]
|
||||
drv_action = OpenNebula::XMLElement.new
|
||||
drv_action.initialize_xml(Base64.decode64(drv_action_enc), 'DS_DRIVER_ACTION_DATA')
|
||||
|
||||
##host_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
|
||||
ds_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/ID"]
|
||||
ds_ref = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_REF"]
|
||||
check_valid ds_ref, "ds_ref"
|
||||
|
||||
##if host_id.nil? || ds_ref.nil?
|
||||
if ds_id.nil? || ds_ref.nil?
|
||||
STDERR.puts "Not enough information to monitor the image."
|
||||
exit -1
|
||||
end
|
||||
|
||||
begin
|
||||
##vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(ds_id)
|
||||
|
||||
storage = VCenterDriver::Storage.new_from_ref(ds_ref, vi_client)
|
||||
|
@ -41,20 +41,16 @@ drv_action.initialize_xml(Base64.decode64(drv_action_enc), 'DS_DRIVER_ACTION_DAT
|
||||
|
||||
ds_ref = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_REF"]
|
||||
ds_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/ID"]
|
||||
##host_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
|
||||
img_src = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/SOURCE"]
|
||||
imported = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/VCENTER_IMPORTED"]
|
||||
|
||||
check_valid ds_ref, "ds_ref"
|
||||
##check_valid host_id, "vcenter_cluster"
|
||||
check_valid img_src, "img_src"
|
||||
|
||||
CDROM = "1"
|
||||
|
||||
begin
|
||||
#TODO should imported disks be deleted?
|
||||
if imported.nil? || imported.empty?
|
||||
##vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(ds_id)
|
||||
|
||||
ds = VCenterDriver::Datastore.new_from_ref(ds_ref, vi_client)
|
||||
|
@ -41,16 +41,13 @@ drv_action.initialize_xml(Base64.decode64(drv_action_enc), 'DS_DRIVER_ACTION_DAT
|
||||
|
||||
ds_ref = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_DS_REF"]
|
||||
ds_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/ID"]
|
||||
#host_id = drv_action["/DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VCENTER_ONE_HOST_ID"]
|
||||
img_path = drv_action["/DS_DRIVER_ACTION_DATA/IMAGE/PATH"]
|
||||
|
||||
check_valid ds_ref, "ds_ref"
|
||||
#check_valid host_id, "vcenter_cluster"
|
||||
check_valid img_path, "img_path"
|
||||
|
||||
if img_path.start_with? "vcenter://"
|
||||
begin
|
||||
##vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(ds_id)
|
||||
|
||||
ds = VCenterDriver::Datastore.new_from_ref(ds_ref, vi_client)
|
||||
|
@ -39,20 +39,16 @@ vcenter_url = ARGV[0]
|
||||
u = URI.parse(vcenter_url)
|
||||
params = CGI.parse(u.query)
|
||||
|
||||
vc_cluster_name = params["param_host"][0]
|
||||
ds_name = params["param_dsname"][0]
|
||||
ds_id = params["param_dsid"][0]
|
||||
img_src = u.host + u.path
|
||||
|
||||
begin
|
||||
vi_client = VCenterDriver::VIClient.new_from_datastore(ds_id)
|
||||
|
||||
host = VCenterDriver::VIHelper.find_by_name(OpenNebula::HostPool, vc_cluster_name)
|
||||
host_id = host['ID']
|
||||
source_ds = VCenterDriver::VIHelper.one_item(OpenNebula::Datastore, ds_id)
|
||||
source_ds_ref = source_ds['TEMPLATE/VCENTER_DS_REF']
|
||||
|
||||
vi_client = VCenterDriver::VIClient.new_from_host(host_id)
|
||||
|
||||
one_ds = VCenterDriver::VIHelper.find_by_name(OpenNebula::DatastorePool, ds_name)
|
||||
|
||||
ds = VCenterDriver::Datastore.new_from_ref(one_ds["TEMPLATE/VCENTER_DS_REF"], vi_client)
|
||||
ds = VCenterDriver::Datastore.new_from_ref(source_ds_ref, vi_client)
|
||||
|
||||
if ds.is_descriptor?(img_src)
|
||||
descriptor_name = File.basename u.path
|
||||
@ -95,8 +91,8 @@ begin
|
||||
end
|
||||
|
||||
rescue Exception => e
|
||||
STDERR.puts "Cannot download image #{u.path} from datastore #{ds_name} "\
|
||||
"on #{hostname}. Reason: \"#{e.message}\"\n#{e.backtrace}"
|
||||
STDERR.puts "Cannot download image #{u.path} from datastore #{ds_id} "\
|
||||
"Reason: \"#{e.message}\"\n#{e.backtrace}"
|
||||
exit -1
|
||||
ensure
|
||||
vi_client.close_connection if vi_client
|
||||
|
@ -157,7 +157,7 @@ void OpenNebulaTemplate::set_multiple_conf_default()
|
||||
set_conf_ds("ssh", "", "NO");
|
||||
set_conf_ds("vmfs", "BRIDGE_LIST", "NO");
|
||||
set_conf_ds("vcenter",
|
||||
"VCENTER_ONE_HOST_ID, VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_CCR_REF",
|
||||
"VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_DC_REF, VCENTER_HOST, VCENTER_USER, VCENTER_PASSWORD",
|
||||
"NO");
|
||||
set_conf_ds("ceph",
|
||||
"DISK_TYPE,BRIDGE_LIST,CEPH_HOST,CEPH_USER,CEPH_SECRET",
|
||||
|
@ -958,8 +958,8 @@ DS_MAD_CONF = [
|
||||
|
||||
DS_MAD_CONF = [
|
||||
NAME = "vcenter",
|
||||
REQUIRED_ATTRS = "VCENTER_ONE_HOST_ID, VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_CCR_REF",
|
||||
PERSISTENT_ONLY = "YES",
|
||||
REQUIRED_ATTRS = "VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_DC_REF, VCENTER_HOST, VCENTER_USER, VCENTER_PASSWORD",
|
||||
PERSISTENT_ONLY = "NO",
|
||||
MARKETPLACE_ACTIONS = "export"
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user