# Error executing image transfer script: Error copying

**URL:** https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271
**Category:** Product Support
**Created:** [November 14, 2016, 9:06am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271 "2016-11-14T09:06:51Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 14, 2016, 9:06am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/1 "2016-11-14T09:06:51Z")

</div>

Hello OpenNebula folk!

I set my new OpenNebula test config.  
1 server with opennebula (192.168.16.113)  
and 1 server (VM) withe the node (192.168.16.112)

Now i follow the installation frond-end and the Node. (Setup maria-db)  
and make sure that the servers can auto login from the user “oneadmin”

I download the image through the webportal (sunstone) and setup the VM om the host 16.112.

Now I get an Error executing image transfer script: Error copying. What can I do?

```
root@opennebula-01:~# tail -f /var/log/one/1.log 

```

Thu Nov 10 15:39:03 2016 [Z0][VM][I]: New state is ACTIVE  
Thu Nov 10 15:39:03 2016 [Z0][VM][I]: New LCM state is PROLOG  
Thu Nov 10 15:39:04 2016 [Z0][TM][I]: Command execution fail: /var/lib/one/remotes/tm/ssh/clone opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 192.168.16.112:/var/lib/one//datastores/0/1/disk.0 1 1  
Thu Nov 10 15:39:04 2016 [Z0][TM][I]: clone: Cloning opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 in /var/lib/one/datastores/0/1/disk.0  
Thu Nov 10 15:39:04 2016 [Z0][TM][E]: clone: Command “scp -r opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 192.168.16.112:/var/lib/one//datastores/0/1/disk.0” failed: Host key verification failed.  
Thu Nov 10 15:39:04 2016 [Z0][TM][E]: Error copying opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 to 192.168.16.112:/var/lib/one//datastores/0/1/disk.0  
Thu Nov 10 15:39:04 2016 [Z0][TM][I]: ExitCode: 1  
Thu Nov 10 15:39:04 2016 [Z0][TM][E]: Error executing image transfer script: Error copying opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 to 192.168.16.112:/var/lib/one//datastores/0/1/disk.0  
Thu Nov 10 15:39:04 2016 [Z0][VM][I]: New LCM state is PROLOG\_FAILURE

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 14, 2016, 10:47am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/2 "2016-11-14T10:47:59Z")

</div>

> [@NetIds](#):
>
> Thu Nov 10 15:39:04 2016 [Z0][TM][E]: clone: Command “scp -r opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 192.168.16.112:/var/lib/one//datastores/0/1/disk.0” failed: Host key verification failed.

This is the problem, can you check that you can ssh from opennebula-01 to 192.168.16.112 as oneadmin?

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 14, 2016, 12:04pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/4 "2016-11-14T12:04:31Z")

</div>

Yes;

root@opennebula-01:~# su oneadmin  
oneadmin@opennebula-01:/home/user$ ssh -v [oneadmin@192.168.16.112](mailto:oneadmin@192.168.16.112)  
OpenSSH\_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 19: Applying options for \*  
debug1: Connecting to 192.168.16.112 [192.168.16.112] port 22.  
debug1: Connection established.  
debug1: identity file /var/lib/one/.ssh/id\_rsa type 1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_rsa-cert type -1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_dsa type -1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_dsa-cert type -1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_ecdsa type -1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_ecdsa-cert type -1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_ed25519 type -1  
debug1: key\_load\_public: No such file or directory  
debug1: identity file /var/lib/one/.ssh/id\_ed25519-cert type -1  
debug1: Enabling compatibility mode for protocol 2.0  
debug1: Local version string SSH-2.0-OpenSSH\_7.2p2 Ubuntu-4ubuntu2.1  
debug1: Remote protocol version 2.0, remote software version OpenSSH\_7.2p2 Ubuntu-4ubuntu2.1  
debug1: match: OpenSSH\_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH\* compat 0x04000000  
debug1: Authenticating to 192.168.16.112:22 as 'oneadmin’  
debug1: SSH2\_MSG\_KEXINIT sent  
debug1: SSH2\_MSG\_KEXINIT received  
debug1: kex: algorithm: [curve25519-sha256@libssh.org](mailto:curve25519-sha256@libssh.org)  
debug1: kex: host key algorithm: ecdsa-sha2-nistp256  
debug1: kex: server-\>client cipher: [chacha20-poly1305@openssh.com](mailto:chacha20-poly1305@openssh.com) MAC: compression: none  
debug1: kex: client-\>server cipher: [chacha20-poly1305@openssh.com](mailto:chacha20-poly1305@openssh.com) MAC: compression: none  
debug1: expecting SSH2\_MSG\_KEX\_ECDH\_REPLY  
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:y8OaTpPizZhwvMqcK2Ry5zzoIc/2My+UMqS8nyQWWy8  
debug1: Host ‘192.168.16.112’ is known and matches the ECDSA host key.  
debug1: Found key in /var/lib/one/.ssh/known\_hosts:2  
debug1: rekey after 134217728 blocks  
debug1: SSH2\_MSG\_NEWKEYS sent  
debug1: expecting SSH2\_MSG\_NEWKEYS  
debug1: rekey after 134217728 blocks  
debug1: SSH2\_MSG\_NEWKEYS received  
debug1: SSH2\_MSG\_EXT\_INFO received  
debug1: kex\_input\_ext\_info: server-sig-algs=\<rsa-sha2-256,rsa-sha2-512\>  
debug1: SSH2\_MSG\_SERVICE\_ACCEPT received  
debug1: Authentications that can continue: publickey,password  
debug1: Next authentication method: publickey  
debug1: Offering RSA public key: /var/lib/one/.ssh/id\_rsa  
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279  
debug1: Authentication succeeded (publickey).  
Authenticated to 192.168.16.112 ([192.168.16.112]:22).  
debug1: channel 0: new [client-session]  
debug1: Requesting [no-more-sessions@openssh.com](mailto:no-more-sessions@openssh.com)  
debug1: Entering interactive session.  
debug1: pledge: network  
debug1: client\_input\_global\_request: rtype [hostkeys-00@openssh.com](mailto:hostkeys-00@openssh.com) want\_reply 0  
debug1: Sending environment.  
debug1: Sending env LANG = en\_US.UTF-8  
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-47-generic x86\_64)

Last login: Thu Nov 10 15:09:55 2016 from 192.168.16.112  
oneadmin@Virtualhost-01:~$

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 14, 2016, 12:05pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/5 "2016-11-14T12:05:18Z")

</div>

What’s the output of:

"scp -r opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 192.168.16.112:/var/lib/one//datastores/0/1/disk.0

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 14, 2016, 12:07pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/6 "2016-11-14T12:07:08Z")

</div>

> [@tinova](#):
>
> scp -r opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 192.168.16.112:/var/lib/one//datastores/0/1/disk.0

root@opennebula-01:~# su oneadmin  
oneadmin@opennebula-01:/home/user$ scp -r opennebula-01:/var/lib/one//datastores/1/b131780d0e08b3a96327cf780bf82dc4 192.168.16.112:/var/lib/one//datastores/0/1/disk.0  
The authenticity of host ‘opennebula-01 (127.0.1.1)’ can’t be established.  
ECDSA key fingerprint is SHA256:jHVQj8TxGIizHH7uD96usrGvrPB/uVX/WOhimCIH9g0.  
Are you sure you want to continue connecting (yes/no)?

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 14, 2016, 6:59pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/7 "2016-11-14T18:59:14Z")

</div>

make sure that you can ssh to localhost as oneadmin in the front-end

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 21, 2016, 1:07pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/8 "2016-11-21T13:07:22Z")

</div>

The ssh connection works tank you! After this was set, the NFS mounted on the frond-end (113) and node (112) and connect the node as a host.

Now I download from the app store a linux image and set it up as a first VM. The download was completed in the data store, but after set an VM I get this error:

Mon Nov 21 13:59:06 2016 : Error executing image transfer script: Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0

Can you help me out? thanks in advance 🙂

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 22, 2016, 9:44am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/9 "2016-11-22T09:44:14Z")

</div>

Could you send us the complete log of the VM? Thanks!

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 22, 2016, 9:49am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/10 "2016-11-22T09:49:19Z")

</div>

Mon Nov 21 13:59:04 2016 [Z0][VM][I]: New state is ACTIVE  
Mon Nov 21 13:59:04 2016 [Z0][VM][I]: New LCM state is PROLOG  
Mon  
Nov 21 13:59:06 2016 [Z0][TM][I]: Command execution fail:  
/var/lib/one/remotes/tm/shared/clone  
opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103  
Mon Nov 21 13:59:06 2016 [Z0][TM][I]: /var/lib/one/remotes/tm/shared/clone: line 94: [: : integer expression expected  
Mon  
Nov 21 13:59:06 2016 [Z0][TM][I]: clone: Cloning  
/var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in  
192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
Mon  
Nov 21 13:59:06 2016 [Z0][TM][E]: clone: Command "cd  
/var/lib/one/datastores/101/10; rm -f  
/var/lib/one/datastores/101/10/disk.0; cp  
/var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
/var/lib/one/datastores/101/10/disk.0 " failed: cp: cannot create  
regular file ‘/var/lib/one/datastores/101/10/disk.0’: Operation not  
permitted  
Mon Nov 21 13:59:06 2016  
[Z0][TM][E]: Error copying  
opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
Mon Nov 21 13:59:06 2016 [Z0][TM][I]: ExitCode: 1  
Mon  
Nov 21 13:59:06 2016 [Z0][TM][E]: Error executing image transfer  
script: Error copying  
opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
Mon Nov 21 13:59:06 2016 [Z0][VM][I]: New LCM state is PROLOG\_FAILURE

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 23, 2016, 12:35pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/11 "2016-11-23T12:35:25Z")

</div>

Can make it have to do with the user “oneadmin”? Because I doesn’t use LDAP and make the user oneadmin manual on the note (VM) because to know the user ID for a good connection for the NFS.

So I can try it with LDAP for the same users with the same ID for a good connection with NFS. Or is the fault elsewhere before I try this option. Thanks for help.

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 23, 2016, 1:03pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/12 "2016-11-23T13:03:09Z")

</div>

It can be a NFS issue. Can you create the following file as oneadmin in the front-end:

```
 /var/lib/one/datastores/101/10/disk.0
```

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 23, 2016, 1:07pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/13 "2016-11-23T13:07:40Z")

</div>

Yes:

root@opennebula-01:~# su oneadmin  
oneadmin@opennebula-01:/home/user$ touch /var/lib/one/datastores/101/10/disk.0  
oneadmin@opennebula-01:/home/user$ cat /var/lib/one/datastores/101/10/disk.0  
oneadmin@opennebula-01:/home/user$ echo “Test” \> /var/lib/one/datastores/101/10/disk.0  
oneadmin@opennebula-01:/home/user$ cat /var/lib/one/datastores/101/10/disk.0  
Test  
oneadmin@opennebula-01:/home/user$

No error on this command

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 25, 2016, 10:10am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/14 "2016-11-25T10:10:57Z")

</div>

What happens if you execute:

cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 25, 2016, 2:54pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/15 "2016-11-25T14:54:16Z")

</div>

oneadmin@opennebula-01:/home/user$ cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0  
oneadmin@opennebula-01:/home/user$  
(No problems)

oneadmin@opennebula-01:/home/user$ ls -lah /var/lib/one/datastores/101/10/disk.0  
-rwxrwxr-x 1 oneadmin oneadmin 40M Nov 25 15:51 /var/lib/one/datastores/101/10/disk.0  
oneadmin@opennebula-01:/home/user$  
(40M = small linux)

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [November 29, 2016, 10:07am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/16 "2016-11-29T10:07:13Z")

</div>

Thanks for the info. Let’s try the driver manually, as oneadmin (we assume oned is running as oneadmin?) in the front-end:

/var/lib/one/remotes/tm/shared/clone  
opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [November 29, 2016, 12:35pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/17 "2016-11-29T12:35:51Z")

</div>

root@opennebula-01:~# su oneadmin  
oneadmin@opennebula-01:/home/user$ /var/lib/one/remotes/tm/shared/clone opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
/usr/lib/ruby/2.3.0/rexml/parsers/treeparser.rb:28:in `parse': No close tag for /vmid (REXML::ParseException) Line: 15 Position: 639 Last 80 unconsumed characters: from /usr/lib/ruby/2.3.0/rexml/document.rb:288:in`build’  
from /usr/lib/ruby/2.3.0/rexml/document.rb:45:in `initialize' from /var/lib/one/remotes/tm/shared/../../datastore/xpath.rb:58:in`new’  
from /var/lib/one/remotes/tm/shared/…/…/datastore/xpath.rb:58:in `'  
ERROR MESSAGE --8\<------  
Error creating directory at /: dirname: missing operand  
Try ‘dirname --help’ for more information.  
ssh: Could not resolve hostname /: Temporary failure in name resolution  
ERROR MESSAGE ------\>8–  
oneadmin@opennebula-01:/home/user$

Did I something wrong in this command? Thanks again for helping 🙂

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [December 2, 2016, 10:49am UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/18 "2016-12-02T10:49:14Z")

</div>

Apologies, I didn’t include the proper arguments:

/var/lib/one/remotes/tm/shared/clone  
opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [December 2, 2016, 4:25pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/19 "2016-12-02T16:25:52Z")

</div>

> [@tinova](#):
>
> /var/lib/one/remotes/tm/shared/clone opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103

root@opennebula-01:~# su oneadmin  
oneadmin@opennebula-01:/home/user$ /var/lib/one/remotes/tm/shared/clone opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103  
/var/lib/one/remotes/tm/shared/clone: line 94: [: : integer expression expected  
INFO: clone: Cloning /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
ERROR: clone: Command "cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 " failed: cp: cannot create regular file ‘/var/lib/one/datastores/101/10/disk.0’: Operation not permitted  
ERROR MESSAGE --8\<------  
Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
ERROR MESSAGE ------\>8–  
oneadmin@opennebula-01:/home/user$

---

<div class="post-metadata">

### Author: ![tinova](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/tinova/32/25_2.png) [@tinova](https://forum.opennebula.io/u/tinova)
#### Post date: [December 2, 2016, 5:24pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/20 "2016-12-02T17:24:51Z")

</div>

We are back to square one. Let’s see if we can get more info:

bash -xv /var/lib/one/remotes/tm/shared/clone opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103

---

<div class="post-metadata">

### Author: ![NetIds](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@NetIds](https://forum.opennebula.io/u/NetIds)
#### Post date: [December 4, 2016, 12:48pm UTC](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271/21 "2016-12-04T12:48:44Z")

</div>

> [@tinova](#):
>
> bash -xv /var/lib/one/remotes/tm/shared/clone opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103

Hee Tiniva, this is the output of if:

root@opennebula-01:~# su oneadmin  
oneadmin@opennebula-01:/home/user$ bash -xv /var/lib/one/remotes/tm/shared/clone opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 192.168.16.112:/var/lib/one//datastores/101/10/disk.0 10 103  
#!/bin/bash

# clone fe:SOURCE host:remote\_system\_ds/disk.i vmid dsid

# - fe is the front-end hostname

# - SOURCE is the path of the disk image in the form DS\_BASE\_PATH/disk

# - host is the target host to deploy the VM

# - remote\_system\_ds is the path for the system datastore in the host

# - vmid is the id of the VM

# - dsid is the target datastore (0 is the system datastore)

SRC=$1

- SRC=opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
DST=$2
- DST=192.168.16.112:/var/lib/one//datastores/101/10/disk.0

VMID=$3

- VMID=10  
DSID=$4
- DSID=103

if [-z “${ONE\_LOCATION}”]; then  
TMCOMMON=/var/lib/one/remotes/tm/tm\_common.sh  
else  
TMCOMMON=$ONE\_LOCATION/var/remotes/tm/tm\_common.sh  
fi

- ‘[’ -z ‘’ ‘]’
- TMCOMMON=/var/lib/one/remotes/tm/tm\_common.sh

. $TMCOMMON

- . /var/lib/one/remotes/tm/tm\_common.sh

export LANG=C  
++ export LANG=C  
++ LANG=C

if [-z “$ONE\_LOCATION”]; then  
ONE\_LOCAL\_VAR=/var/lib/one  
ONE\_LIB=/usr/lib/one  
DS\_DIR=/var/lib/one/datastores  
else  
ONE\_LOCAL\_VAR=$ONE\_LOCATION/var  
ONE\_LIB=$ONE\_LOCATION/lib  
DS\_DIR=$ONE\_LOCATION/var/datastores  
fi  
++ ‘[’ -z ‘’ ‘]’  
++ ONE\_LOCAL\_VAR=/var/lib/one  
++ ONE\_LIB=/usr/lib/one  
++ DS\_DIR=/var/lib/one/datastores

ONE\_SH=$ONE\_LIB/sh  
++ ONE\_SH=/usr/lib/one/sh

. $ONE\_SH/scripts\_common.sh  
++ . /usr/lib/one/sh/scripts\_common.sh

# --------------------------------------------------------------------------

# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems

# 

# Licensed under the Apache License, Version 2.0 (the “License”); you may

# not use this file except in compliance with the License. You may obtain

# a copy of the License at

# 

# [Apache License, Version 2.0 | Apache Software Foundations](http://www.apache.org/licenses/LICENSE-2.0)

# 

# Unless required by applicable law or agreed to in writing, software

# distributed under the License is distributed on an “AS IS” BASIS,

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

# See the License for the specific language governing permissions and

# limitations under the License.

#--------------------------------------------------------------------------- #

export LANG=C  
+++ export LANG=C  
+++ LANG=C

# Paths for utilities

export PATH=/bin:/sbin:/usr/bin:$PATH  
+++ export PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games  
+++ PATH=/bin:/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games  
AWK=${AWK:-awk}  
+++ AWK=awk  
BASH=${BASH:-bash}  
+++ BASH=/bin/bash  
CUT=${CUT:-cut}  
+++ CUT=cut  
CEPH=${CEPH:-ceph}  
+++ CEPH=ceph  
DATE=${DATE:-date}  
+++ DATE=date  
DD=${DD:-dd}  
+++ DD=dd  
DF=${DF:-df}  
+++ DF=df  
DU=${DU:-du}  
+++ DU=du  
GREP=${GREP:-grep}  
+++ GREP=grep  
ISCSIADM=${ISCSIADM:-iscsiadm}  
+++ ISCSIADM=iscsiadm  
LVCREATE=${LVCREATE:-lvcreate}  
+++ LVCREATE=lvcreate  
LVREMOVE=${LVREMOVE:-lvremove}  
+++ LVREMOVE=lvremove  
LVCHANGE=${LVCHANGE:-lvchange}  
+++ LVCHANGE=lvchange  
LVSCAN=${LVSCAN:-lvscan}  
+++ LVSCAN=lvscan  
LVS=${LVS:-lvs}  
+++ LVS=lvs  
LN=${LN:-ln}  
+++ LN=ln  
MD5SUM=${MD5SUM:-md5sum}  
+++ MD5SUM=md5sum  
MKFS=${MKFS:-mkfs}  
+++ MKFS=mkfs  
MKISOFS=${MKISOFS:-genisoimage}  
+++ MKISOFS=genisoimage  
MKSWAP=${MKSWAP:-mkswap}  
+++ MKSWAP=mkswap  
QEMU\_IMG=${QMEMU\_IMG:-qemu-img}  
+++ QEMU\_IMG=qemu-img  
RADOS=${RADOS:-rados}  
+++ RADOS=rados  
RBD=${RBD:-rbd}  
+++ RBD=rbd  
READLINK=${READLINK:-readlink}  
+++ READLINK=readlink  
RM=${RM:-rm}  
+++ RM=rm  
CP=${CP:-cp}  
+++ CP=cp  
SCP=${SCP:-scp}  
+++ SCP=scp  
SED=${SED:-sed}  
+++ SED=sed  
SSH=${SSH:-ssh}  
+++ SSH=ssh  
SUDO=${SUDO:-sudo}  
+++ SUDO=sudo  
SYNC=${SYNC:-sync}  
+++ SYNC=sync  
TAR=${TAR:-tar}  
+++ TAR=tar  
TGTADM=${TGTADM:-tgtadm}  
+++ TGTADM=tgtadm  
TGTADMIN=${TGTADMIN:-tgt-admin}  
+++ TGTADMIN=tgt-admin  
TGTSETUPLUN=${TGTSETUPLUN:-tgt-setup-lun-one}  
+++ TGTSETUPLUN=tgt-setup-lun-one  
TR=${TR:-tr}  
+++ TR=tr  
VGDISPLAY=${VGDISPLAY:-vgdisplay}  
+++ VGDISPLAY=vgdisplay  
VMKFSTOOLS=${VMKFSTOOLS:-vmkfstools}  
+++ VMKFSTOOLS=vmkfstools  
WGET=${WGET:-wget}  
+++ WGET=wget

if [“x$(uname -s)” = “xLinux”]; then  
SED=“$SED -r”  
else  
SED=“/usr/bin/sed -E”  
fi  
uname -s  
++++ uname -s  
+++ ‘[’ xLinux = xLinux ‘]’  
+++ SED=‘sed -r’

# Used for log messages

SCRIPT\_NAME=`basename $0`  
basename $0  
++++ basename /var/lib/one/remotes/tm/shared/clone  
+++ SCRIPT\_NAME=clone

# ------------------------------------------------------------------------------

# Path manipulation functions

# ------------------------------------------------------------------------------

# Takes out unneeded slashes. Repeated and final directory slashes:

# /some//path///somewhere/ → /some/path/somewhere

function fix\_dir\_slashes  
{  
dirname “$1/file” | $SED ‘s//+///g’  
}

# ------------------------------------------------------------------------------

# Log functions

# ------------------------------------------------------------------------------

# Formats date for logs

function log\_date  
{  
$DATE +“%a %b %d %T %Y”  
}

# Logs a message, alias to log\_info

function log  
{  
log\_info “$1”  
}

# Log function that knows how to deal with severities and adds the

# script name

function log\_function  
{  
echo “$1: $SCRIPT\_NAME: $2” 1\>&2  
}

# Logs an info message

function log\_info  
{  
log\_function “INFO” “$1”  
}

# Logs an error message

function log\_error  
{  
log\_function “ERROR” “$1”  
}

# Logs a debug message

function log\_debug  
{  
log\_function “DEBUG” “$1”  
}

# This function is used to pass error message to the mad

function error\_message  
{  
(  
echo “ERROR MESSAGE --8\<------”  
echo “$1”  
echo “ERROR MESSAGE ------\>8–”  
) 1\>&2  
}

# Executes a command, if it fails returns error message and exits

# If a second parameter is present it is used as the error message when

# the command fails

function exec\_and\_log  
{  
message=$2

```
EXEC_LOG_ERR=`$1 2>&1 1>/dev/null`
EXEC_LOG_RC=$?

if [$EXEC_LOG_RC -ne 0]; then
    log_error "Command \"$1\" failed: $EXEC_LOG_ERR"

    if [-n "$2"]; then
        error_message "$2"
    else
        error_message "Error executing $1: $EXEC_LOG_ERR"
    fi
    exit $EXEC_LOG_RC
fi

```

}

# This function executes $1 and returns stdout

# If a second parameter is present it is used as the error message when

# the command fails

function monitor\_and\_log  
{  
EXEC\_OUT=“$(bash -s 2\>/dev/null \<\<EOF  
export LANG=C  
export LC\_ALL=C  
set -xv  
$1  
EOF  
)”  
EXEC\_RC=$?

```
if [$EXEC_RC -ne 0]; then

    if [-n "$2"]; then
        log_error "Command \"$2\" failed: $EXEC_OUT"
    else
        log_error "Command \"$1\" failed: $EXEC_OUT"
    fi

    exit $EXEC_RC
fi

echo "$EXEC_OUT"

```

}

# Executes a command, if it fails returns error message and exits. Similar to

# exec\_and\_log, except that it allows multiline commands.

# If a second parameter is present it is used as the error message when

# the command fails.

function multiline\_exec\_and\_log  
{  
message=$2

```
EXEC_LOG_ERR=`bash -s 2>&1 1>/dev/null <<EOF

```

export LANG=C  
export LC\_ALL=C  
$1  
EOF`  
EXEC\_LOG\_RC=$?

```
if [$EXEC_LOG_RC -ne 0]; then
    log_error "Command \"$1\" failed: $EXEC_LOG_ERR"

    if [-n "$2"]; then
        error_message "$2"
    else
        error_message "Error executing $1: $EXEC_LOG_ERR"
    fi
    exit $EXEC_LOG_RC
fi

```

}

# Like exec\_and\_log but does not exit on failure. Just sets the variable

# ERROR to the error message.

function exec\_and\_set\_error  
{  
message=$2

```
EXEC_LOG_ERR=$(bash -c "$1" 2>&1 1>/dev/null)
EXEC_LOG_RC=$?

export ERROR=""

if [$EXEC_LOG_RC -ne 0]; then
    log_error "Command \"$1\" failed: $EXEC_LOG_ERR"

    if [-n "$2"]; then
        export ERROR="$2"
    else
        export ERROR="Error executing $1: $EXEC_LOG_ERR"
    fi
fi

```

}

# Like exec\_and\_log but the first argument is the number of seconds

# before here is timeout and kills the command

# 

# NOTE: if the command is killed because a timeout the exit code

# will be 143 = 128+15 (SIGHUP)

function timeout\_exec\_and\_log  
{  
TIMEOUT=$1  
shift

```
CMD="$1"

exec_and_log "$CMD" &
CMD_PID=$!

# timeout process
(
    sleep $TIMEOUT
    kill $CMD_PID 2>/dev/null
    log_error "Timeout executing $CMD"
    error_message "Timeout executing $CMD"
    exit -1
) &
TIMEOUT_PID=$!

# stops the execution until the command finalizes
wait $CMD_PID 2>/dev/null
CMD_CODE=$?

# if the script reaches here the command finished before it
# consumes timeout seconds so we can kill timeout process
kill $TIMEOUT_PID 2>/dev/null 1>/dev/null
wait $TIMEOUT_PID 2>/dev/null

# checks the exit code of the command and exits if it is not 0
if ["x$CMD_CODE" != "x0"]; then
    exit $CMD_CODE
fi

```

}

# Parameters are times (seconds) and monitoring command (or function).

# Executes monitoring command until it is successful (VM is no longer

# running) or the timeout is reached.

function retry  
{  
times=$1  
function=$2

```
count=1

ret=$($function)
error=$?

while [$count -lt $times -a "$error" != "0"]; do
    sleep 1
    count=$(( $count + 1 ))
    ret=$($function)
    error=$?
done

["x$error" = "x0"]

```

}

# Parameters are deploy\_id and cancel command. If the last command is

# unsuccessful and $FORCE\_DESTROY=yes then calls cancel command

function force\_shutdown {  
error=$?  
deploy\_id=$1  
command=$2

```
if ["x$error" != "x0"]; then
    if ["$FORCE_DESTROY" = "yes"]; then
        log_error "Timeout shutting down $deploy_id. Destroying it"
        $($command)
        sleep 2
    else
        error_message "Timed out shutting down $deploy_id"
        exit -1
    fi
fi

```

}

# This function will return a command that upon execution will format a

# filesystem with its proper parameters based on the filesystem type

function mkfs\_command {  
DST=$1  
FSTYPE=$2  
SIZE=${3:-0}

```
if ["$FSTYPE" = "qcow2"]; then
    QEMU_FORMAT="qcow2"
else
    QEMU_FORMAT="raw"
fi

echo "$QEMU_IMG create -f ${QEMU_FORMAT} ${DST} ${SIZE}M"

if ["$FSTYPE" = "swap"]; then
    echo "$MKSWAP -L swap $DST"
fi

```

}

#This function executes $2 at $1 host and report error $3 but does not exit  
function ssh\_exec\_and\_log\_no\_error  
{  
SSH\_EXEC\_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF export LANG=C export LC_ALL=C $2 EOF`  
SSH\_EXEC\_RC=$?

```
if [$SSH_EXEC_RC -ne 0]; then
    log_error "Command \"$2\" failed: $SSH_EXEC_ERR"

    if [-n "$3"]; then
        error_message "$3"
    else
        error_message "Error executing $2: $SSH_EXEC_ERR"
    fi

    return $SSH_EXEC_RC
fi

return 0

```

}

#This function executes $2 at $1 host and report error $3  
function ssh\_exec\_and\_log  
{  
ssh\_exec\_and\_log\_no\_error “$@”  
EXEC\_RC=$?

```
if ["$EXEC_RC" != "0"]; then
    exit $EXEC_RC
fi

```

}

# Remote command execution over SSH preloading a local file

# $1: HOSTNAME

# $2: COMMAND

# $3: file to be loaded into the script

# $4: ERROR\_REPORT

function ssh\_exec\_and\_log\_stdin  
{  
SSH\_EXEC\_ERR=`$SSH $1 bash -s 2\>&1 1\>/dev/null \<\<EOF  
export LANG=C  
export LC\_ALL=C  
$(cat $3)

$2  
EOF`

```
SSH_EXEC_RC=$?

if [$SSH_EXEC_RC -ne 0]; then
    log_error "Command \"$2\" failed: $SSH_EXEC_ERR"

    if [-n "$4"]; then
        error_message "$4"
    else
        error_message "Error executing $2: $SSH_EXEC_ERR"
    fi

    exit $SSH_EXEC_RC
fi

```

}

# This function executes $2 at $1 host and returns stdout

# If $3 is present, it is used as the error message when

# the command fails

function ssh\_monitor\_and\_log  
{  
SSH\_EXEC\_OUT=“$($SSH $1 bash -s 2\>/dev/null \<\<EOF  
export LANG=C  
export LC\_ALL=C  
$2  
EOF  
)”  
SSH\_EXEC\_RC=$?

```
if [$SSH_EXEC_RC -ne 0]; then

    if [-n "$3"]; then
        log_error "Command \"$3\" failed: $SSH_EXEC_OUT"
    else
        log_error "Command \"$2\" failed: $SSH_EXEC_OUT"
    fi

    exit $SSH_EXEC_RC
fi

echo "$SSH_EXEC_OUT"

```

}

# Creates path ($2) at $1. If there is a third parameter it is writen as

# file “.monitor” in the directory. Used for local disk monitoring

function ssh\_make\_path  
{  
SSH\_EXEC\_ERR=`$SSH $1 bash -s 2\>&1 1\>/dev/null \<\<EOF  
set -e -o pipefail  
if [! -d $2]; then  
mkdir -p $2

if [-n “$3”]; then  
echo “$3” \> “$(dirname $2)/.monitor”  
fi  
fi  
EOF`  
SSH\_EXEC\_RC=$?

```
if [$SSH_EXEC_RC -ne 0]; then
    error_message "Error creating directory $2 at $1: $SSH_EXEC_ERR"

    exit $SSH_EXEC_RC
fi

```

}

# TODO → Use a dynamically loaded scripts directory. Not removing this due

# to iSCSI addon: [GitHub - OpenNebula/addon-iscsi: Storage driver for iSCSI](https://github.com/OpenNebula/addon-iscsi)

# ------------------------------------------------------------------------------

# iSCSI functions

# ------------------------------------------------------------------------------

#-------------------------------------------------------------------------------

# Returns the command to create a new target

# @param $1 - ID of the image

# @param $2 - Target Host

# @param $3 - Device

# @return the command to create a new target

#-------------------------------------------------------------------------------

function tgtadm\_target\_new {  
ID=“$1”  
IQN=“$2”

```
echo "$TGTADM --lld iscsi --op new --mode target --tid $ID "\
    "--targetname $IQN"

```

}

function tgtadm\_target\_bind\_all {  
ID=“$1”  
echo “$TGTADM --lld iscsi --op bind --mode target --tid $ID -I ALL”  
}

function tgtadm\_logicalunit\_new {  
ID=“$1”  
DEV=“$2”

```
echo "$TGTADM --lld iscsi --op new --mode logicalunit --tid $ID "\
    "--lun 1 --backing-store $DEV"

```

}

function tgtadm\_target\_delete {  
ID=“$1”  
echo “$TGTADM --lld iscsi --op delete --mode target --tid $ID”  
}

function tgtadm\_get\_tid\_for\_iqn {  
IQN=“$1”  
echo “$TGTADM --lld iscsi --op show --mode target | strings |   
grep "$IQN" | awk ‘{split($2,tmp,":"); print(tmp[1]);}’”  
}

function tgtadm\_next\_tid {  
echo “$TGTADM --lld iscsi --op show --mode target | strings |   
$GREP "Target" | tail -n 1 |   
$AWK ‘{split($2,tmp,":"); print tmp[1]+1;}’”  
}

function tgt\_admin\_dump\_config {  
FILE\_PATH=“$1”  
echo “$TGTADMIN --dump |sudo tee $FILE\_PATH \> /dev/null 2\>&1”  
}

### 

function iscsiadm\_discovery {  
TARGET\_HOST=“$1”  
echo “$ISCSIADM -m discovery -t st -p $TARGET\_HOST”  
}

function iscsiadm\_login {  
IQN=“$1”  
TARGET\_HOST=“$2”  
echo “$ISCSIADM -m node --targetname $IQN -p $TARGET\_HOST --login”  
}

function iscsiadm\_logout {  
IQN=“$1”  
echo “$ISCSIADM -m node --targetname $IQN --logout”  
}

function is\_iscsi {  
if echo “$NO\_ISCSI”|grep -q “\b$1\b”; then  
return 1  
else  
return 0  
fi  
}

# Checks wether $IMAGE\_TYPE is CDROM

function is\_cdrom {  
[“$IMAGE\_TYPE” = “1”]  
}

function iqn\_get\_lv\_name {  
IQN=“$1”  
TARGET=`echo "$IQN"|$CUT -d: -f2`  
echo $TARGET|$AWK -F. ‘{print $(NF)}’  
}

function iqn\_get\_vg\_name {  
IQN=“$1”  
TARGET=`echo "$IQN"|$CUT -d: -f2`  
echo $TARGET|$AWK -F. ‘{print $(NF-1)}’  
}

function tgt\_setup\_lun\_install {  
DST\_HOST=“$1”  
BASE\_PATH=“$2”

```
CHECK_FILE="$BASE_PATH/.tgt-setup-lun"

if [! -f "$CHECK_FILE"]; then
    $SSH "$DST_HOST" "$SUDO $TGTSETUPLUN" 2>&1 | \
        $GREP -q "command not found"
    if ["$?" = "0"]; then
        error_message "$TGTSETUPLUN is not installed in $DST_HOST."
        exit 127
    else
        touch "$CHECK_FILE"
    fi
fi

```

}

function tgt\_setup\_lun {  
IQN=“$1”  
DEV=“$2”  
echo “$TGTSETUPLUN -d $DEV -n $IQN 1\>&2”  
}

function iqn\_get\_host {  
IQN=“$1”  
TARGET=`echo "$IQN"|$CUT -d: -f2`  
LV\_NAME=$(iqn\_get\_lv\_name “$IQN”)  
VG\_NAME=$(iqn\_get\_vg\_name “$IQN”)  
echo ${TARGET%%.$VG\_NAME.$LV\_NAME}  
}

# ------------------------------------------------------------------------------

# VMM helpers

# ------------------------------------------------------------------------------

# This function builds the XML necessary for attach-disk operations

# that require declaration of host sources

# @param $1 - Space separated list of hosts

# @return The XML via STDOUT

function get\_source\_xml {  
for host in $1 ; do  
BCK\_IFS=$IFS  
IFS=‘:’

```
    unset k HOST_PARTS SOURCE_HOST

    for part in $host ; do
        HOST_PARTS[k++]="$part"
    done

    SOURCE_HOST="$SOURCE_HOST<host name='${HOST_PARTS[0]}'"

    if [-n "${HOST_PARTS[1]}" ]; then
        SOURCE_HOST="$SOURCE_HOST port='${HOST_PARTS[1]}'"
    fi

    SOURCE_HOST="$SOURCE_HOST/>"

    IFS=$BCK_IFS
done

echo "$SOURCE_HOST"

```

}

# ------------------------------------------------------------------------------

# Function to get hosts and paths from arguments

# ------------------------------------------------------------------------------

# Gets the host from an argument

function arg\_host  
{  
echo $1 | $SED ‘s/^([^:]_):._$/\1/’  
}

# Gets the path from an argument

function arg\_path  
{  
ARG\_PATH=`echo $1 | $SED 's/^[^:]*:(.*)$/\1/'`  
fix\_dir\_slashes “$ARG\_PATH”  
}

#Return 1 if the first argument is a disk  
function is\_disk  
{  
echo “$1” | $GREP ‘/disk.[0-9]+’ \> /dev/null 2\>&1

```
if [$? -eq 0]; then
    echo "1"
else
    echo "0"
fi

```

}

#Makes path src ($1) relative to dst ($2)  
function make\_relative {  
src=$1  
dst=$2

```
common=$dst

while [-z "`echo $src | grep -E "^$common"`"]; do
    common=`dirname $common`
    dots="../$dots"
done

echo $dots${src#$common/}

```

}

#Return DISK\_TYPE  
function disk\_type  
{  
# Let’s check if it is a CDROM  
DISK\_ID=$(echo “$DST\_PATH” | $AWK -F. ‘{print $NF}’)  
XPATH=“${ONE\_LOCAL\_VAR}/remotes/datastore/xpath.rb --stdin”

```
unset i XPATH_ELEMENTS

while IFS= read -r -d '' element; do
    XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
                    /VM/TEMPLATE/DISK[DISK_ID=$DISK_ID]/TYPE )

DISK_TYPE="${XPATH_ELEMENTS[0]}"

echo $DISK_TYPE

```

}

#Return LCM\_STATE  
function lcm\_state  
{  
XPATH=“${ONE\_LOCAL\_VAR}/remotes/datastore/xpath.rb --stdin”

```
unset i XPATH_ELEMENTS

while IFS= read -r -d '' element; do
    XPATH_ELEMENTS[i++]="$element"
done < <(onevm show -x $VMID| $XPATH \
                    /VM/LCM_STATE )

LCM_STATE="${XPATH_ELEMENTS[0]}"

echo $LCM_STATE

```

}

function migrate\_other  
{  
DRIVER\_PATH=$(dirname $0)  
MAD=${DRIVER\_PATH##\*/}

```
XPATH="$DRIVER_PATH/../../datastore/xpath.rb"

unset i
while IFS= read -r -d '' element; do
    XPATH_ELEMENTS[i++]="$element"
done< <("$XPATH" -b "$6" \
        /VM/TEMPLATE/CONTEXT/DISK_ID \
        %m%/VM/TEMPLATE/DISK/DISK_ID \
        %m%/VM/TEMPLATE/DISK/CLONE \
        %m%/VM/TEMPLATE/DISK/TM_MAD)

unset i
CONTEXT_DISK_ID="${XPATH_ELEMENTS[i++]}"
DISK_IDS="${XPATH_ELEMENTS[i++]}"
CLONES="${XPATH_ELEMENTS[i++]}"
TM_MADS="${XPATH_ELEMENTS[i++]}"
DISK_ID_ARRAY=($DISK_IDS)
CLONE_ARRAY=($CLONES)
TM_MAD_ARRAY=($TM_MADS)

if [-n "$7"]; then
    return 0
fi

for i in ${!TM_MAD_ARRAY[@]}; do
    TM="${TM_MAD_ARRAY[i]}"

    if ["$TM" = "$MAD"]; then
        continue
    fi
    if ["${PROCESSED/ $TM /}" = "$PROCESSED"]; then
        # call the other TM_MADs with same arguments
        # but mark that it is not SYSTEM_DS
        log "Call $TM/${0##*/}"
        "${DRIVER_PATH}/../$TM/${0##*/}" "$@" "$MAD"
        PROCESSED+=" $TM "
    fi
done

```

}

DRIVER\_PATH=$(dirname $0)  
dirname $0  
++ dirname /var/lib/one/remotes/tm/shared/clone

- DRIVER\_PATH=/var/lib/one/remotes/tm/shared

#-------------------------------------------------------------------------------

# Set dst path and dir

#-------------------------------------------------------------------------------  
DST\_PATH=`arg_path $DST`  
arg\_path $DST  
++ arg\_path 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
echo $1 | $SED ‘s/\[1\]_:(._)$/\1/’  
+++ echo 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
+++ sed -r ‘s/\[2\]_:(._)$/\1/’  
++ ARG\_PATH=/var/lib/one//datastores/101/10/disk.0  
++ fix\_dir\_slashes /var/lib/one//datastores/101/10/disk.0  
++ dirname /var/lib/one//datastores/101/10/disk.0/file  
++ sed -r ‘s//+///g’

- DST\_PATH=/var/lib/one/datastores/101/10/disk.0  
DST\_HOST=`arg_host $DST`  
arg\_host $DST  
++ arg\_host 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
++ echo 192.168.16.112:/var/lib/one//datastores/101/10/disk.0  
++ sed -r ‘s/^([^:]_):._$/\1/’
- DST\_HOST=192.168.16.112  
DST\_DIR=`dirname $DST_PATH`  
dirname $DST\_PATH  
++ dirname /var/lib/one/datastores/101/10/disk.0
- DST\_DIR=/var/lib/one/datastores/101/10

SRC\_ARG\_PATH=`arg_path $SRC`  
arg\_path $SRC  
++ arg\_path opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
echo $1 | $SED ‘s/\[3\]_:(._)$/\1/’  
+++ echo opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
+++ sed -r ‘s/\[4\]_:(._)$/\1/’  
++ ARG\_PATH=/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
++ fix\_dir\_slashes /var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
++ dirname /var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6/file  
++ sed -r ‘s//+///g’

- SRC\_ARG\_PATH=/var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6

DST\_DS\_PATH=“$(dirname $(dirname $(dirname $DST\_PATH)))”  
dirname $(dirname $(dirname $DST\_PATH))  
dirname $(dirname $DST\_PATH)  
dirname $DST\_PATH  
++++ dirname /var/lib/one/datastores/101/10/disk.0  
+++ dirname /var/lib/one/datastores/101/10  
++ dirname /var/lib/one/datastores/101

- DST\_DS\_PATH=/var/lib/one/datastores  
SRC\_DS\_PATH=“$(dirname $(dirname $SRC\_ARG\_PATH))”  
dirname $(dirname $SRC\_ARG\_PATH)  
dirname $SRC\_ARG\_PATH  
+++ dirname /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6  
++ dirname /var/lib/one/datastores/103
- SRC\_DS\_PATH=/var/lib/one/datastores

SRC\_PATH=“${DST\_DS\_PATH}${SRC\_ARG\_PATH##$SRC\_DS\_PATH}”

- SRC\_PATH=/var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6

#-------------------------------------------------------------------------------

# Get Image information

#-------------------------------------------------------------------------------

DISK\_ID=$(basename ${DST\_PATH} | cut -d. -f2)  
basename ${DST\_PATH} | cut -d. -f2  
++ basename /var/lib/one/datastores/101/10/disk.0  
++ cut -d. -f2

- DISK\_ID=0

XPATH=“${DRIVER\_PATH}/../../datastore/xpath.rb --stdin”

- XPATH=‘/var/lib/one/remotes/tm/shared/../../datastore/xpath.rb --stdin’

unset i j XPATH\_ELEMENTS

- unset i j XPATH\_ELEMENTS

while IFS= read -r -d ‘’ element; do  
XPATH\_ELEMENTS[i++]=“$element”  
done \< \<(onevm show -x $VMID| $XPATH   
/VM/TEMPLATE/DISK[DISK\_ID=$DISK\_ID]/SIZE   
/VM/TEMPLATE/DISK[DISK\_ID=$DISK\_ID]/ORIGINAL\_SIZE   
/VM/HISTORY\_RECORDS/HISTORY[last()]/TM\_MAD)

- IFS=
- read -r -d ‘’ element  
onevm show -x $VMID| $XPATH /VM/TEMPLATE/DISK[DISK\_ID=$DISK\_ID]/SIZE /VM/TEMPLATE/DISK[DISK\_ID=$DISK\_ID]/ORIGINAL\_SIZE /VM/HISTORY\_RECORDS/HISTORY[last()]/TM\_MAD  
++ onevm show -x 10  
++ /var/lib/one/remotes/tm/shared/../../datastore/xpath.rb --stdin ‘/VM/TEMPLATE/DISK[DISK\_ID=0]/SIZE’ ‘/VM/TEMPLATE/DISK[DISK\_ID=0]/ORIGINAL\_SIZE’ ‘/VM/HISTORY\_RECORDS/HISTORY[last()]/TM\_MAD’
- XPATH\_ELEMENTS[i++]=40
- IFS=
- read -r -d ‘’ element
- XPATH\_ELEMENTS[i++]=
- IFS=
- read -r -d ‘’ element
- XPATH\_ELEMENTS[i++]=shared
- IFS=
- read -r -d ‘’ element

SIZE=“${XPATH\_ELEMENTS[j++]}”

- SIZE=40  
ORIGINAL\_SIZE=“${XPATH\_ELEMENTS[j++]}”
- ORIGINAL\_SIZE=  
TM\_MAD=“${XPATH\_ELEMENTS[j++]}”
- TM\_MAD=shared

if [“$TM\_MAD” = “ssh”]; then  
MONITOR=“ssh”  
else  
MONITOR=“”  
fi

- ‘[’ shared = ssh ‘]’
- MONITOR=

#-------------------------------------------------------------------------------

# Create DST path

#-------------------------------------------------------------------------------

ssh\_make\_path $DST\_HOST $DST\_DIR $MONITOR

- ssh\_make\_path 192.168.16.112 /var/lib/one/datastores/101/10  
$SSH $1 bash -s 2\>&1 1\>/dev/null \<\<EOF  
set -e -o pipefail  
if [! -d $2]; then  
mkdir -p $2

- SSH\_EXEC\_ERR=‘dirname $2  
+++ dirname /var/lib/one/datastores/101/10’

- SSH\_EXEC\_RC=0

- ‘[’ 0 -ne 0 ‘]’

#-------------------------------------------------------------------------------

# Clone (cp) SRC into DST

#-------------------------------------------------------------------------------

if [-n “$ORIGINAL\_SIZE” -a “$SIZE” -gt “$ORIGINAL\_SIZE”]; then  
RESIZE\_CMD=“; qemu-img resize ${DST\_PATH} ${SIZE}M”  
fi

- ‘[’ -n ‘’ -a 40 -gt ‘’ ‘]’  
/var/lib/one/remotes/tm/shared/clone: line 94: [: : integer expression expected

log “Cloning $SRC\_PATH in $DST”

- log ‘Cloning /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’
- log\_info ‘Cloning /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’
- log\_function INFO ‘Cloning /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’
- echo ‘INFO: clone: Cloning /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’  
INFO: clone: Cloning /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 in 192.168.16.112:/var/lib/one//datastores/101/10/disk.0

CLONE\_CMD=“cd ${DST\_DIR};   
rm -f ${DST\_PATH};   
cp ${SRC\_PATH} ${DST\_PATH}   
${RESIZE\_CMD}”

- CLONE\_CMD='cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 ’

ssh\_exec\_and\_log $DST\_HOST   
“$CLONE\_CMD”   
“Error copying $SRC to $DST”

- ssh\_exec\_and\_log 192.168.16.112 'cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 ’ ‘Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’
- ssh\_exec\_and\_log\_no\_error 192.168.16.112 'cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 ’ ‘Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’  
$SSH $1 bash -s 2\>&1 1\>/dev/null \<\<EOF  
export LANG=C  
export LC\_ALL=C  
$2  
EOF  
++ ssh 192.168.16.112 bash -s
- SSH\_EXEC\_ERR=‘cp: cannot create regular file ‘'’/var/lib/one/datastores/101/10/disk.0’'‘: Operation not permitted’
- SSH\_EXEC\_RC=1
- ‘[’ 1 -ne 0 ‘]’
- log\_error ‘Command "cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 " failed: cp: cannot create regular file ‘'’/var/lib/one/datastores/101/10/disk.0’'‘: Operation not permitted’
- log\_function ERROR ‘Command "cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 " failed: cp: cannot create regular file ‘'’/var/lib/one/datastores/101/10/disk.0’'‘: Operation not permitted’
- echo ‘ERROR: clone: Command "cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 " failed: cp: cannot create regular file ‘'’/var/lib/one/datastores/101/10/disk.0’'‘: Operation not permitted’  
ERROR: clone: Command "cd /var/lib/one/datastores/101/10; rm -f /var/lib/one/datastores/101/10/disk.0; cp /var/lib/one/datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 /var/lib/one/datastores/101/10/disk.0 " failed: cp: cannot create regular file ‘/var/lib/one/datastores/101/10/disk.0’: Operation not permitted
- ‘[’ -n ‘Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’ ‘]’
- error\_message ‘Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’
- echo ‘ERROR MESSAGE --8\<------’  
ERROR MESSAGE --8\<------
- echo ‘Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0’  
Error copying opennebula-01:/var/lib/one//datastores/103/d394b97809d7a1b02d3fdac2fd6793a6 to 192.168.16.112:/var/lib/one//datastores/101/10/disk.0
- echo ‘ERROR MESSAGE ------\>8–’  
ERROR MESSAGE ------\>8–
- return 1
- EXEC\_RC=1
- ‘[’ 1 ‘!=’ 0 ‘]’
- exit 1  
oneadmin@opennebula-01:/home/user$

* * *

1. ^: 

2. ^: 

3. ^: 

4. ^:

[Next page](https://forum.opennebula.io/t/error-executing-image-transfer-script-error-copying/3271.md?page=2)
