ExpatError: no element found: line 1

Asked by Premananda Acharya

The request and response to nova-api is as follows:
root@SVCLO-OSS-COMPUTE-VM01:~# telnet localhost 8774
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST http://10.1.168.158:8774/v1.1/servers HTTP/1.1
Content-Type:application/xml
Accept:application/xml
X-Auth-Token:59bb0bbfde79a5515af96ab94d3698279d05c43e
<?xml version="1.0" encoding="UTF-8"?><server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"></server>

HTTP/1.1 500 Internal Server Error
Content-Length: 180
Content-Type: application/xml; charset=UTF-8
Date: Thu, 28 Jul 2011 10:34:44 GMT

<cloudServersFault code="500" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <message>
        no element found: line 1, column 0
    </message>
</cloudServersFault>

Connection closed by foreign host.
root@SVCLO-OSS-COMPUTE-VM01:~#
root@SVCLO-OSS-COMPUTE-VM01:~#

The nova-api log displays :
2011-07-28 06:34:44,828 DEBUG routes.middleware [-] No route matched for POST /servers from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:97
2011-07-28 06:34:44,828 DEBUG routes.middleware [-] Matched POST /servers from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:100
2011-07-28 06:34:44,829 DEBUG routes.middleware [-] Route path: '/servers', defaults: {'action': u'create', 'controller': <nova.api.openstack.servers.ControllerV11 object at 0x25d6390>} from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:102
2011-07-28 06:34:44,829 DEBUG routes.middleware [-] Match dict: {'action': u'create', 'controller': <nova.api.openstack.servers.ControllerV11 object at 0x25d6390>} from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:103
2011-07-28 06:34:44,829 ERROR nova.api.openstack [-] Caught error: no element found: line 1, column 0
(nova.api.openstack): TRACE: Traceback (most recent call last):
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/__init__.py", line 59, in __call__
(nova.api.openstack): TRACE: return req.get_response(self.application)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/request.py", line 919, in get_response
(nova.api.openstack): TRACE: application, catch_exc_info=False)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/request.py", line 887, in call_application
(nova.api.openstack): TRACE: app_iter = application(self.environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
(nova.api.openstack): TRACE: resp = self.call_func(req, *args, **self.kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
(nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/wsgi.py", line 354, in __call__
(nova.api.openstack): TRACE: result = method(**arg_dict)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/servers.py", line 115, in create
(nova.api.openstack): TRACE: env = self._deserialize_create(req)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/servers.py", line 197, in _deserialize_create
(nova.api.openstack): TRACE: return deserializer.deserialize(request.body)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/servers.py", line 665, in deserialize
(nova.api.openstack): TRACE: dom = minidom.parseString(string)
(nova.api.openstack): TRACE: File "/usr/lib/python2.6/xml/dom/minidom.py", line 1928, in parseString
(nova.api.openstack): TRACE: return expatbuilder.parseString(string)
(nova.api.openstack): TRACE: File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
(nova.api.openstack): TRACE: return builder.parseString(string)
(nova.api.openstack): TRACE: File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
(nova.api.openstack): TRACE: parser.Parse(string, True)
(nova.api.openstack): TRACE: ExpatError: no element found: line 1, column 0
(nova.api.openstack): TRACE:
The novarcfile is as below:
NOVA_KEY_DIR=$(pushd $(dirname $BASH_SOURCE)>/dev/null; pwd; popd>/dev/null)
export EC2_ACCESS_KEY="b444d0ed-aba8-4a11-8953-db98141aad46:project1"
export EC2_SECRET_KEY="c5e77cec-6340-4ec8-b787-1971df6219ae"
export EC2_URL="http://10.1.168.158:8773/services/Cloud"
export S3_URL="http://10.1.168.158:3333"
export EC2_USER_ID=42 # nova does not use user id, but bundling requires it
export EC2_PRIVATE_KEY=${NOVA_KEY_DIR}/pk.pem
export EC2_CERT=${NOVA_KEY_DIR}/cert.pem
export NOVA_CERT=${NOVA_KEY_DIR}/cacert.pem
export EUCALYPTUS_CERT=${NOVA_CERT} # euca-bundle-image seems to require this set
alias ec2-bundle-image="ec2-bundle-image --cert ${EC2_CERT} --privatekey ${EC2_PRIVATE_KEY} --user 42 --ec2cert ${NOVA_CERT}"
alias ec2-upload-bundle="ec2-upload-bundle -a ${EC2_ACCESS_KEY} -s ${EC2_SECRET_KEY} --url ${S3_URL} --ec2cert ${NOVA_CERT}"
export NOVA_API_KEY="b444d0ed-aba8-4a11-8953-db98141aad46"
export NOVA_USERNAME="admin"
export NOVA_URL="http://10.1.168.158:8774/v1.0/"
~
the nova.conf file is as below:
--dhcpbridge_flagfile=/etc/nova/nova.conf
--dhcpbridge=/usr/bin/nova-dhcpbridge
--logdir=/var/log/nova
--state_path=/var/lib/nova
--lock_path=/var/lock/nova
--verbose
--s3_host=10.1.168.158
--rabbit_host=10.1.168.158
--cc_host=10.1.168.158
--ec2_url=http://10.1.168.158:8773/services/Cloud
--fixed_range=10.0.0.0/12
--network_size=10
--FAKE_subdomain=ec2
--routing_source_ip=10.1.168.158
--verbose
--sql_connection=mysql://root:root@10.1.168.158/nova
--network_manager=nova.network.manager.FlatManager
--allow_admin_api=true

Question :
The request to create instance fails ,but I can create instance from the euca-run-instance command.Kindly guide.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
Premananda Acharya
Solved:
Last query:
Last reply:
Revision history for this message
Brian Waldon (bcwaldon) said :
#1

It looks like your http request formatting was a bit off. Make sure you put two newlines after your headers. Nonetheless, this is a bug in our xml parsing that needs to be addressed. I'll take care of filing/fixing. I want to make sure your issue is fixed first, though :)

Revision history for this message
Premananda Acharya (premananda-acharya) said :
#2

Hi Bryan ,
I don't get any success.I tried the way suggested introduced a new line/2 lines before the xml but it always has the same exception.The ways I tried are as follows :

Try1 :
POST http://127.0.0.1:8774/v1.1/servers HTTP/1.1
Content-Type:application/xml
Accept:application/xml
X-Auth-Token:00c5be2342a5cadeed050119fa3c688f48cfea1f

<?xml version="1.0" encoding="UTF-8"?><server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"></server>

Try2:
POST http://127.0.0.1:8774/v1.1/servers HTTP/1.1
Content-Type:application/xml
Accept:application/xml
X-Auth-Token:00c5be2342a5cadeed050119fa3c688f48cfea1f \n \n <?xml version="1.0" encoding="UTF-8"?><server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"></server>

HTTP/1.1 401 Unauthorized
Content-Length: 372
Content-Type: application/xml; charset=UTF-8
Date: Fri, 29 Jul 2011 03:50:20 GMT

<unauthorized code="401" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <message>
        This server could not verify that you are authorized to
access the document you requested. Either you supplied the
wrong credentials (e.g., bad password), or your browser
does not understand how to supply the credentials required.

    </message>
</unauthorized>

Connection closed by foreign host.
administrator@SVCLO-OSS-COMPUTE-VM01:~$

Try3:
POST http://127.0.0.1:8774/v1.1/servers HTTP/1.1
Content-Type:application/xml
Accept:application/xml
X-Auth-Token:00c5be2342a5cadeed050119fa3c688f48cfea1f \n
<?xml version="1.0" encoding="UTF-8"?><server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"></server>

HTTP/1.1 401 Unauthorized
Content-Length: 372
Content-Type: application/xml; charset=UTF-8
Date: Fri, 29 Jul 2011 03:51:00 GMT

<unauthorized code="401" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <message>
        This server could not verify that you are authorized to
access the document you requested. Either you supplied the
wrong credentials (e.g., bad password), or your browser
does not understand how to supply the credentials required.

    </message>
</unauthorized>

Connection closed by foreign host.
administrator@SVCLO-OSS-COMPUTE-VM01:~$

Try 4 :
POST http://127.0.0.1:8774/v1.1/servers HTTP/1.1
Content-Type:application/xml
Accept:application/xml
X-Auth-Token:00c5be2342a5cadeed050119fa3c688f48cfea1f\n
<?xml version="1.0" encoding="UTF-8"?><server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"></server>

HTTP/1.1 401 Unauthorized
Content-Length: 372
Content-Type: application/xml; charset=UTF-8
Date: Fri, 29 Jul 2011 03:51:40 GMT

<unauthorized code="401" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <message>
        This server could not verify that you are authorized to
access the document you requested. Either you supplied the
wrong credentials (e.g., bad password), or your browser
does not understand how to supply the credentials required.

    </message>
</unauthorized>

Connection closed by foreign host.
administrator@SVCLO-OSS-COMPUTE-VM01:~$

try5:
POST http://127.0.0.1:8774/v1.1/servers HTTP/1.1
Content-Type:application/xml
Accept:application/xml
X-Auth-Token:00c5be2342a5cadeed050119fa3c688f48cfea1f

HTTP/1.1 500 Internal Server Error
Content-Length: 180
Content-Type: application/xml; charset=UTF-8
Date: Fri, 29 Jul 2011 03:52:35 GMT

<cloudServersFault code="500" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <message>
        no element found: line 1, column 0
    </message>
</cloudServersFault>
<?xml version="1.0" encoding="UTF-8"?><server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"></server>
<head>
<title>Error response</title>
</head>
<body>
<h1>Error response</h1>
<p>Error code 400.
<p>Message: Bad request syntax ('&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;server xmlns="http://docs.rackspacecloud.com/servers/api/v1.0" name="hello" imageId="1389280188" flavorId="1"&gt;&lt;/server&gt;').
<p>Error code explanation: 400 = Bad request syntax or unsupported method.
</body>
Connection closed by foreign host.
administrator@SVCLO-OSS-COMPUTE-VM01:~$
administrator@SVCLO-OSS-COMPUTE-VM01:~$

Can you pleasse help me how do i set the xml at the right place ?Is there any escape character needs to be introduced for the new line other than "\n" when I try to pass the request directly in port 8774 ? Please suggest .

Revision history for this message
Brian Waldon (bcwaldon) said :
#3

Below is a sample telnet session I just made. Newlines are entered with the Enter/Return key on your keyboard. Typing '\n' will actually send those characters. Also, make sure you send a Content-Length header. The server will not read your body properly otherwise.

root@nova1:~# telnet localhost 8774
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
POST http://localhost:8774/v1.1/servers HTTP/1.1
Accept: */*
X-Auth-Token: 2ac2e649adf4e60aaf0f45b24c4a38d8688747cb
Content-Type: application/xml
Content-Length: 96

<?xml version="1.0" encoding="UTF-8"?><server name="hello" imageRef="3" flavorRef="1"></server>
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 609
Date: Fri, 29 Jul 2011 19:05:15 GMT

{"server": {"status": "BUILD", "updated": "2011-07-29 19:05:15.435981", "hostId": "", "addresses": {}, "links": [{"href": "http://127.0.0.1:8774/v1.1/servers/5", "rel": "self"}, {"href": "http://127.0.0.1:8774/servers/5", "rel": "bookmark"}], "created": "2011-07-29 19:05:15", "image": {"id": "3", "links": [{"href": "http://127.0.0.1:8774/images/3", "rel": "bookmark"}]}, "adminPass": "A5TAFWZedY6yw6Pr", "uuid": "be32bd14-0e44-4c47-b302-619c640c1b17", "progress": 0, "flavor": {"id": "1", "links": [{"href": "http://127.0.0.1:8774/flavors/1", "rel": "bookmark"}]}, "metadata": {}, "id": 5, "name": "hello"}}

Revision history for this message
Brian Waldon (bcwaldon) said :
#4

I would also suggest you use a utility like 'curl' to make HTTP requests. It handles the request construction for you and helps prevents you from making silly mistakes. Here's an example:

curl -X POST -d '<?xml version="1.0" encoding="UTF-8"?><server name="hello" imageRef="3" flavorRef="1"></server>' -H 'Content-Type: application/xml' -H 'X-Auth-Token: 2ac2e649adf4e60aaf0f45b24c4a38d8688747cb' -H 'Accept: application/xml' http://localhost:8774/v1.1/servers

Revision history for this message
Premananda Acharya (premananda-acharya) said :
#5

Hi Bryan,
I tried the utility as suggested.

The command as used :

administrator@SVCLO-OSS-COMPUTE-VM01:~$ curl -X POST -d '<?xml version="1.0" encoding="UTF-8"?><server name="hello" flavorRef="1" imageRef="1389280188"></server>' -H 'Content-Type: application/xml' -H 'X-Auth-Token:28e1ebd8b283564110f022c3fd2083a6bbda0ee7' -H 'Accept: application/xml' http://localhost:8774/v1.1/servers
<cloudServersFault code="500" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <message>
        'imageRef'
    </message>
</cloudServersFault>

The log in nova-api.log:

2011-08-01 01:26:42,001 DEBUG routes.middleware [-] Matched POST /servers from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:100
2011-08-01 01:26:42,001 DEBUG routes.middleware [-] Route path: '/servers', defaults: {'action': u'create', 'controller': <nova.api.openstack.servers.ControllerV11 object at 0x25d6390>} from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:102
2011-08-01 01:26:42,001 DEBUG routes.middleware [-] Match dict: {'action': u'create', 'controller': <nova.api.openstack.servers.ControllerV11 object at 0x25d6390>} from (pid=9629) __call__ /usr/lib/pymodules/python2.6/routes/middleware.py:103
2011-08-01 01:26:42,003 ERROR nova.api.openstack [-] Caught error: 'imageRef'
(nova.api.openstack): TRACE: Traceback (most recent call last):
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/__init__.py", line 59, in __call__
(nova.api.openstack): TRACE: return req.get_response(self.application)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/request.py", line 919, in get_response
(nova.api.openstack): TRACE: application, catch_exc_info=False)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/request.py", line 887, in call_application
(nova.api.openstack): TRACE: app_iter = application(self.environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/routes/middleware.py", line 131, in __call__
(nova.api.openstack): TRACE: response = self.app(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 159, in __call__
(nova.api.openstack): TRACE: return resp(environ, start_response)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 147, in __call__
(nova.api.openstack): TRACE: resp = self.call_func(req, *args, **self.kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/webob/dec.py", line 208, in call_func
(nova.api.openstack): TRACE: return self.func(req, *args, **kwargs)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/wsgi.py", line 354, in __call__
(nova.api.openstack): TRACE: result = method(**arg_dict)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/servers.py", line 129, in create
(nova.api.openstack): TRACE: requested_image_id = self._image_id_from_req_data(env)
(nova.api.openstack): TRACE: File "/usr/lib/pymodules/python2.6/nova/api/openstack/servers.py", line 615, in _image_id_from_req_data
(nova.api.openstack): TRACE: href = data['server']['imageRef']
(nova.api.openstack): TRACE: KeyError: 'imageRef'
(nova.api.openstack): TRACE:

It shows that imageRef is wrong ,but when i pass the GET command for the inages I get the below :
GET http://10.1.168.158/v1.0/images/detail HTTP/1.1
Content-Type: application/xml
Accept: application/xml
X-Auth-Token: 28e1ebd8b283564110f022c3fd2083a6bbda0ee7

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 508
Date: Mon, 01 Aug 2011 05:35:01 GMT

<images xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <image created="None" id="995875194" name="None" status="ACTIVE" updated="None"/>
    <image created="None" id="1389280188" name="None" status="ACTIVE" updated="None"/>
    <image created="None" id="1833758643" name="None" status="ACTIVE" updated="None"/>
    <image created="None" id="990095796" name="None" status="ACTIVE" updated="None"/>
    <image created="None" id="1010877198" name="None" status="ACTIVE" updated="None"/>
</images>

Connection closed by foreign host.
administrator@SVCLO-OSS-COMPUTE-VM01:~$

which suggests that imageRef is correct ?

Where am i doing wrong...please suggest .

Revision history for this message
Premananda Acharya (premananda-acharya) said :
#6

When I changed the request to the format below it solved my issue...looks like a bug in openstack...where it gives response saying the current version is v1.1 and v1.0 is deprecated but takes the resuest as v1.0

administrator@SVCLO-OSS-COMPUTE-VM01:~$ curl -X POST -d '<?xml version="1.1" encoding="UTF-8"?><server name="Bholenath" imageId="1389280188" flavorId="1"></server>' -H 'Content-Type: application/xml' -H 'X-Auth-Token:28e1ebd8b283564110f022c3fd2083a6bbda0ee7' -H 'Accept: application/xml' http://localhost:8774/v1.0/servers
<server adminPass="GWYy4SeGJLMqND7v" flavorId="1" hostId="" id="4" imageId="1389280188" name="Bholenath" status="BUILD" xmlns="http://docs.rackspacecloud.com/servers/api/v1.0">
    <addresses>
        <public/>
        <private/>
    </addresses>
    <metadata/>
</server>

Revision history for this message
Premananda Acharya (premananda-acharya) said :
#7

Above steps solved my problem,I request Bryan to file a bug and fix this.

Revision history for this message
Brian Waldon (bcwaldon) said :
#8

It appears that the version of Nova you are running doesn't handle xml deserialization correctly. I tested the exact request you posted above and it passed for me on the latest Nova revision against the v1.1 endpoint. Try updating to the latest trunk build.