mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
B#1474 images registered by premigrator through templates have the same permissions (#2264)
* B#1474 images registered by premigrator through templates have the same permissions * B#1474 Now it use the [] operator to access the xml
This commit is contained in:
parent
1db429e363
commit
b8b1796ddf
@ -1054,6 +1054,24 @@ def template_unmanaged_discover(devices, ccr_name, ccr_ref,
|
||||
|
||||
image_size = get_image_size(RbVmomi::VIM::Datastore.new(vi_client.vim, ds_ref), image_path_escaped)
|
||||
|
||||
template_pool = OpenNebula::TemplatePool.new(one_client)
|
||||
template_pool.info(-1, template_id.to_i, template_id.to_i)
|
||||
|
||||
#get owner
|
||||
uid_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/UID"]
|
||||
gid_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/GID"]
|
||||
|
||||
#get permissions
|
||||
owu_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/OWNER_U"]
|
||||
owm_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/OWNER_M"]
|
||||
owa_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/OWNER_A"]
|
||||
gu_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/GROUP_U"]
|
||||
gm_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/GROUP_M"]
|
||||
ga_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/GROUP_A"]
|
||||
ou_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/OTHER_U"]
|
||||
om_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/OTHER_M"]
|
||||
oa_image = template_pool["/VMTEMPLATE_POOL/VMTEMPLATE/PERMISSIONS/OTHER_A"]
|
||||
|
||||
#Create image
|
||||
one_image = ""
|
||||
one_image << "NAME=\"#{image_name}\"\n"
|
||||
@ -1068,6 +1086,12 @@ def template_unmanaged_discover(devices, ccr_name, ccr_ref,
|
||||
rc = one_i.allocate(one_image, ds["ID"].to_i)
|
||||
raise "\n ERROR! Could not create image for template #{template_name}. Reason #{rc.message}" if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = one_i.chown(uid_image.to_i, gid_image.to_i)
|
||||
raise "\n ERROR! Could not set the owner for image #{image_name}. Reason #{rc.message}" if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = one_i.chmod(owu_image.to_i, owm_image.to_i, owa_image.to_i, gu_image.to_i, gm_image.to_i, ga_image.to_i, ou_image.to_i, om_image.to_i, oa_image.to_i)
|
||||
raise "\n ERROR! Could not set the permissions for image #{image_name}. Reason #{rc.message}" if OpenNebula.is_error?(rc)
|
||||
|
||||
rc = one_i.info
|
||||
raise "\n ERROR! Could not get image info for template #{template_name}. Reason #{rc.message}" if OpenNebula.is_error?(rc)
|
||||
STDOUT.puts "--- Image #{one_i["NAME"]} with ID #{one_i["ID"]} has been created"
|
||||
|
Loading…
x
Reference in New Issue
Block a user