Ask Your Question
1

nova-network api "create network" error 404

asked 2014-11-28 11:50:56 -0500

rok gravatar image

updated 2014-12-04 11:02:27 -0500

Hi, I'm trying to use some of Openstack APIs, I get "Error 404 Resource not found" when trying to use "Create Network" in a java program. I have devstack all-in-one .

http://developer.openstack.org/api-re...

Is there any known problem? I'm referring to nova-network, not neutron. I'm able to create a network via CLI (not via API calling). Any help will be appreciated. This is the code I'm using:

    private final static String NOVA_ENDPOINT = "http://127.0.0.1:8774/v2/";
    String network = "{\"network\": {\"label\": \"new net 111\", \"cidr\": \"10.20.105.0/24\" }}"
    [...]
    JsonObject jo = (JsonObject)json.parse(network);
    Response response = client.target(NOVA_ENDPOINT+tenant_id)
                .request(MediaType.APPLICATION_JSON)
                .header("X-Auth-Token", authToken)
                .post(Entity.json(gson.toJson(jo)));

    String responseJson = response.readEntity(String.class);

If I use command "nova network-create" from CLI works properly, but If I call the API via CLI, same error 404.. seems to be a problem related to the API, maybe because nova-network is deprecated?

[NEW] After suggestion of echiu I provide more details..

I tried with REST Console, getting same error... this is a summary of what I just did with REST Console:

TARGET:

Request URI: http://172.22.173.160:8774/v2/7f7bea3...

Request Method: POST

Accept: text/plain (if I choose application/json same error)

BODY:

Content-type: text/plain (if I choose application/json same error)

Raw Body: {"network": { "label": "new net 111", "cidr": "10.20.105.0/24}}

Custom Header: X-Auth-Token ff5982d881a7489cba89d44cebaec364

Left empty all other fields. I get error 404, Resource not found. I'm sure about my tenant ID and Token ID, I took that with CLI command keystone token-get, and if I try the API "List Networks" wich is a GET with this endpoint:

http://172.22.173.160:8774/v2/7f7bea3...

(Note that the endpoint is the same, except for the last part /os-networks ...so my url is correct I think) Everything works fine! It is strange, because I can properly create a network with CLI command

nova network-create Prova --fixed-range-v4 172.22.173.165/24

As user echiu said CLI commands invokes Rest API... so what's wrong with my API call? I remember that I'm using Devstack All-in-one without Neutron and I'm trying to use this API of nova-network:

http://developer.openstack.org/api-re...

edit retag flag offensive close merge delete

Comments

1

You'll probably want to post your code so users can compare it to the documentation.

mpetason gravatar imagempetason ( 2014-12-02 16:45:44 -0500 )edit

Ok I'm going to edit my question with the code, but I think the problem is not related to it, because other nova-network API are working properly and I use a similar java code.. could be my problem related to the fact that nova-network is deprecated?

rok gravatar imagerok ( 2014-12-03 02:50:10 -0500 )edit

Awesome. Now at least a Dev has a starting point. I would also recommend trying out one of the Dev rooms in IRC:

https://wiki.openstack.org/wiki/IRC

mpetason gravatar imagempetason ( 2014-12-03 08:54:27 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-12-03 16:06:26 -0500

echiu gravatar image

updated 2014-12-03 17:49:25 -0500

The Openstack CLI tools are python scripts which invoke REST APIs, so if you are able to create the network in CLI but not directly in your REST API call this tells us the following:

  1. The REST API endpoint exists.
  2. You are not creating the right URL in your REST API call, hence the HTTP 404 error.

First, try to validate the URL is correct and working in a developer tool such as REST Console https://chrome.google.com/webstore/de...

Then generate the URL and print in your Java code, but comment out the actual REST API call. Only when you are sure you are generating the correct URLs, then make the REST API call. It is easier to debug this way on client-side vs the server-side. To debug on the server-side, you would have to look at the openstack logs, but there are many logs in /var/logs and this is more difficult.

edit flag offensive delete link more

Comments

I did some tests with REST Console, but same error... btw I've edited my question, take a look..

rok gravatar imagerok ( 2014-12-04 11:03:09 -0500 )edit

If you are getting HTTP 404 error with the REST Console, then the web endpoint is invalid. You can find valid examples of Nova API calls in your log file at /var/log/nova/nova-api.log Use the CLI to invoke Openstack changes, then look in your nova-api.log for REST API examples.

echiu gravatar imageechiu ( 2014-12-11 19:21:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-11-28 11:50:56 -0500

Seen: 723 times

Last updated: Dec 04 '14