"oneimage create" without copying the image

I’m not sure which version it changed, but in 3.8 at least, we could do the following:

oneimage create --name … --type OS --source /var/lib/one/datastores/1/image_file

This let us copy images between different clusters/environments, and create an image using the same image_file filename, and avoiding it cloning the image file to a randomly generated filename like it does if you use --path in 4.x

If we can’t do that anymore, is there any way of setting the final filename that the image will clone to rather than random?

Hi,

That command should still work as you described. What version are you using?

opennebula-4.12.1-1

$ ls -l /var/lib/one/images/
total 5218564
-rw-rw-r-- 1 oneadmin oneadmin 5343805440 Jun  8 10:03 0cd903f65634b259006a9bab8eb56da5

$ oneimage create -d default --name "test-oneimage-create" --type OS --source /var/lib/one/images/0cd903f65634b259006a9bab8eb56da5
[ImageAllocate] Cannot determine Image SIZE. Wrong number or missing SIZE attribute.

hi Andy,

seems like you’re missing the --size attribute ?

–size size Size in MB. Used for DATABLOCK type or SOURCE based images.

source: http://docs.opennebula.org/doc/4.12/cli/oneimage.1.html

Yes it works if you specify SIZE manually, but its a local file, we shouldn’t need to specify it since the tool has access to it, and we never needed to specify it in previous versions as it worked out the size itself, but somewhere along the line it now requires you to provide it.

hi Andy, just remembered I had seen the error before, in the (NFS-mounted) /var/lib/one folder.
I wasnt able to add images from a directory like /var/lib/one/upload
If I mounted that same dir as /mnt/upload it would work ok.

the error message was similar: [ImageAllocate] Cannot determine Image SIZE.

Hi

The need to set SIZE is a requirement of images registered providing SOURCE
(as opposed to set PATH and let the drivers set the source). In this case
(setting SOURCE) the stat action of the driver is not invoked. Using SOURCE
is target to recovery situations.

Cheers

Hello,
Sorry for resurrecting 4 years old thread but I am facing similar problem that becomes quite annoying.

Let me explain:

  • I have recent OpenNebula 5.6 installation with NFS datastore and I am trying to migrate qcow2 images from old Archipel orchestration system via “oneimage create”. I have to nfs mount previous system under /var/tmp to be able to import old images.
    the command looks like this
    oneimage create --name “os-oldvps1” --type OS --description “old vps1” --path=/var/tmp/vms1/vm/drives/e9757498-6926-11e4-9b45-001e67121b2c/vps1.qcow2 -d imgfsds --driver qcow2
    (where /var/tmp/vms1 is NFS share mounted from old server)
    The problem is that oneimage creates temporary copy under /var/tmp first and /var/tmp size is quite limited - I have 100-500gb image files and /var/tmp has only 35Gb available. Not to mention the speed of the whole procedure - copy from NFS to local disk, only to copy it agan to another NFS share.

Is there a way to force the location of temporary files for oneimage? Ideally I’d point it somewhere else on the same NFS share where I have my datastore, so that temp image->ds image operation would be almost instant.

Could somebody please point me to right direction?

Could you share the XML of your image datastore?

Sure

<DATASTORE>
  <ID>103</ID>
  <UID>0</UID>
  <GID>0</GID>
  <UNAME>oneadmin</UNAME>
  <GNAME>oneadmin</GNAME>
  <NAME>imgfsds</NAME>
  <PERMISSIONS>
    <OWNER_U>1</OWNER_U>
    <OWNER_M>1</OWNER_M>
    <OWNER_A>0</OWNER_A>
    <GROUP_U>1</GROUP_U>
    <GROUP_M>0</GROUP_M>
    <GROUP_A>0</GROUP_A>
    <OTHER_U>0</OTHER_U>
    <OTHER_M>0</OTHER_M>
    <OTHER_A>0</OTHER_A>
  </PERMISSIONS>
  <DS_MAD><![CDATA[fs]]></DS_MAD>
  <TM_MAD><![CDATA[qcow2]]></TM_MAD>
  <BASE_PATH><![CDATA[/var/lib/one//datastores/103]]></BASE_PATH>
  <TYPE>0</TYPE>
  <DISK_TYPE>0</DISK_TYPE>
  <STATE>0</STATE>
  <CLUSTERS>
    <ID>0</ID>
  </CLUSTERS>
  <TOTAL_MB>5364404</TOTAL_MB>
  <FREE_MB>5235688</FREE_MB>
  <USED_MB>128716</USED_MB>
  <IMAGES>
    <ID>39</ID>
    <ID>40</ID>
    <ID>41</ID>
    <ID>42</ID>
    <ID>43</ID>
    <ID>47</ID>
    <ID>49</ID>
    <ID>50</ID>
    <ID>51</ID>
    <ID>52</ID>
    <ID>53</ID>
    <ID>54</ID>
    <ID>55</ID>
    <ID>56</ID>
    <ID>57</ID>
    <ID>58</ID>
  </IMAGES>
  <TEMPLATE>
    <ALLOW_ORPHANS><![CDATA[NO]]></ALLOW_ORPHANS>
    <BRIDGE_LIST><![CDATA[10.0.5.1]]></BRIDGE_LIST>
    <CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
    <CLONE_TARGET_SSH><![CDATA[SYSTEM]]></CLONE_TARGET_SSH>
    <DISK_TYPE><![CDATA[FILE]]></DISK_TYPE>
    <DISK_TYPE_SSH><![CDATA[FILE]]></DISK_TYPE_SSH>
    <DRIVER><![CDATA[qcow2]]></DRIVER>
    <DS_MAD><![CDATA[fs]]></DS_MAD>
    <LN_TARGET><![CDATA[NONE]]></LN_TARGET>
    <LN_TARGET_SSH><![CDATA[SYSTEM]]></LN_TARGET_SSH>
    <RESTRICTED_DIRS><![CDATA[/]]></RESTRICTED_DIRS>
    <SAFE_DIRS><![CDATA[/var/tmp /home]]></SAFE_DIRS>
    <TM_MAD><![CDATA[qcow2]]></TM_MAD>
    <TM_MAD_SYSTEM><![CDATA[SELF]]></TM_MAD_SYSTEM>
    <TYPE><![CDATA[IMAGE_DS]]></TYPE>
  </TEMPLATE>
</DATASTORE>

Any hope? if it needs to have transit temp copy it’s ok by me. how can I force oneimage to make this transit copy somewhere else? Why doesn’t it honor TMPDIR/TMP/TEMP environment variables?

It seems that you are using a BRIDGE_LIST so the STAGING_DIR is been used as temp folder for copying the images. Default value for STAGING_DIR is /var/tmp (http://docs.opennebula.org/5.8/operation/host_cluster_management/datastore_guide.html?highlight=staging_dir#datastore-definition).

You can try defining the STAGING_DIR for you datastores and set it to a convenient path.

1 Like

Thank you that works perfect.
There was just some element of surprise - I assumed that oneimage create operations are async and independent, and started importing 2 images at the same time - 1st 3.7Gb and 2nd - 15Gb while watching the progress - to my surprise 3.7Gb image was created sooner, but tmp file was just sitting there waiting for 15Gb image to finish creating - why is it so?
Upd:
Delayed thought - for the BRIDGE_LIST attribute of image datastore - if I will clear it will oneimage create import image file without staging copy?