BhushanP
Contributor
Contributor

Create OVF/OVA via ovftool

Hi,

I have a ESXi 5.0 server running which has a Guest VM running CentOS 5.6.

The ESXi server is a standalone server, not included in a datacenter, not managed by vCenter.

The server has a HDD of 80G which has both the ESXi host & the Guest OS running on top of it.

I installed ovftools on my Windows laptop & tried to create a ovf from the VM but am unsuccessful. I constantly get the following error -

c:\>ovftool vi://root:<rootpassword>@<ESXi Host IP>/datastore1/CentOS c:\testVM.ovf

Error: Cannot parse locater: vi://root:<rootpassword>@<ESXi Host IP>/datastore1/CentOS

Completed with errors

The local datastore name is "datastore1"

Can someone help me out here with forming the correct the ovftool command to create an ovf & possibly an OVA out of the running VM?

Thanks

Bhushan Pathak

Thanks Bhushan Pathak
32 Replies
BhushanP
Contributor
Contributor

Still no success. Get the same curl error -

ovftool -st=VI "vi://<ESX Host IP>" test.ovf

Entered username & password

Error: Curl error: URL using bad/illegal format or missing URL

Completed with errors

I will try installing the linx version on a machine & try out. Will update in a few hours.

Thanks

Bhushan Pathak

Thanks Bhushan Pathak
0 Kudos
BhushanP
Contributor
Contributor

The Guest VM is powered off. Is that the problem? [The tool trying to connect to the VM but cannot as it is turned off]

Thanks

Bhushan Pathak

Thanks Bhushan Pathak
0 Kudos
kjb007
Immortal
Immortal

You know, I think we've been going about this the wrong way.  If you just want to have a copy of your vm.  Then log in through the vSphere client, shutdown your vm.  It has to be shutdown for the vm to be exported.  Then, go up to your vSphere client  File --> Export --> Export OVF Template.  This will allow you to select OVF/OVA, and put it where you want.

Gets away from the ovftool all together.  If you need the ovftool to work specifically, we can continue.

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
0 Kudos
BhushanP
Contributor
Contributor

I had already tried the vSphere client way of creating a OVA, which worked.

What I am currently looking at is automate it from CLI, which is why I am using ovftool.

I additionally tried the ovftool commands from a Linux system, no joy.

Still running into the same errors

Thanks

Bhushan Pathak

Thanks Bhushan Pathak
0 Kudos
BhushanP
Contributor
Contributor

SUCCESS at last. I removed the # character from the password & it worked for me from Linux CLI, Smiley Happy

Should work in windows environment too, will test that.

Thanks for your help, I really appreciate it.

Bhushan Pathak

Thanks Bhushan Pathak
0 Kudos
BhushanP
Contributor
Contributor

Thanks to KjB for sticking with me to solve the issue.

Additionally, the tool should print more verbose/helpful messages to figure out what the error is

Thanks Bhushan Pathak
0 Kudos
kjb007
Immortal
Immortal

Agreed.  Some of my biggest gripes have come from lack of proper error messages.

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
0 Kudos
kjb007
Immortal
Immortal

No problem

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
0 Kudos
Kyrra
Contributor
Contributor

I ran into this same issue.  I had a password with the hash character "#", and ovftool kept failing to allow me to connect.  I changed my password and everything worked just fine.

I was getting the same error the original poster of this thread had:

   Error: Curl error: URL using bad/illegal format or missing URL

Maybe it has to do with having a # at the end of the password?  Reguardless, this is an annoying bug.

0 Kudos
slaclair
VMware Employee
VMware Employee

Kyrra wrote:

I ran into this same issue.  I had a password with the hash character "#", and ovftool kept failing to allow me to connect.  I changed my password and everything worked just fine.

I was getting the same error the original poster of this thread had:

   Error: Curl error: URL using bad/illegal format or missing URL

Maybe it has to do with having a # at the end of the password?  Reguardless, this is an annoying bug.

I'll back this up, these Curl errors were getting the absolute best of me.  I changed the ESXi password to 'password' and everything worked perfect.  Just make sure whatever password that you choose for it is RFC-friendly.

VCAP5-DCD/DCA/CIA, VCA4-DT
BhushanP
Contributor
Contributor

Hi slaclair,

Can you specify the RFC to be followed?

Thanks

Bhushan

Thanks Bhushan Pathak
slaclair
VMware Employee
VMware Employee

Brushan,

While I never saw it documented anywhere, I made sure to make the special characters of my ESX passwords fall in compliance of RFC 1738 and Curl never gave me a problem since.

Steve

VCAP5-DCD/DCA/CIA, VCA4-DT
GonenG
Contributor
Contributor

Brushan, Steve,

Solved this by converting any special characters in the username and password to "URL-Safe" characters,
for example:

' ' should be written as '%20' (blank)

'!' should be written as '%21'

'\' should be written as '%5C'

You can actually convert ALL characters in the username and/or password to "URL-Safe" characters,

just to make sure you have a valid identifier for the ovftool.

Here is a one-liner in Perl:

$string =~ s/(.)/sprintf("%%%X",ord($1))/eg;  # (each char in $string is converted to its Hex-rep., for example: '!' --> '%21')

Gonen

0 Kudos