0

which fields are required in creating server for v2.1? I send these data but it has the below error.

{"computeFault":{"code":500,"message":"Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible."}}

Are there any other parameters that I should send?

input:

'server' => [
    "name" => "new-server-test",
    "flavorRef" => "ea...",
    "OS-DCF:diskConfig" => "AUTO",
    "imageRef" => "8a...",
    "key_name" => "mykey",
    "user_data" => "QWR.W4="
]

How can I achieve user_data? I read in the documentation that it is the configuration information or scripts to use upon launch. Must be Base64 encoded. However, I do not know how to get it via api.

Edit: I send request to :8774/v2.1/servers by curl. I have the admin token in the header. I also added the networks parameter in the server array as the input but It doesnot work.

'networks'  => [
    ['uuid' => 'network_id']
],

I am using Victoria. My current version by sending request to :8774 is 2.87. Its id is 2.1.

input:

{"server":{"name":"new-server-test","flavorRef":"ea...","OS-DCF:diskConfig":"AUTO","imageRef":"8ad...","key_name":"mykey","networks":[{"uuid":"8ce..."}]}}
Bani
  • 19
  • 6
  • You probably need a network or port. I don't know what this `user_data` is supposed to mean; can you share a link to the documentation you are using? – berndbausch Feb 17 '21 at 12:07
  • Also, how exactly you submit the API. – berndbausch Feb 17 '21 at 12:22
  • @berndbausch Thanks. I have edited my post. – Bani Feb 17 '21 at 12:32
  • When you submit an API request directly, your data must be in JSON format. The format in your question looks like Ruby. No wonder it is rejected. See the [API documentation](https://docs.openstack.org/api-ref/compute/?expanded=show-server-details-detail#create-server). – berndbausch Feb 17 '21 at 14:01
  • 1
    To start, I would use a minimum of fields. In particular, `user_data` looks tricky. Just leave it out. Minimum should be image, flavor, network or port. – berndbausch Feb 17 '21 at 14:08
  • @berndbausch my data is in the form of json. I have also `Content-Type: application/json` in the header. I have image, flavor and network but it but it has the error. – Bani Feb 20 '21 at 05:00
  • This: `'networks' => [ ['uuid' => 'network_id'] ], ` is not JSON. Why don't you add the complete command to your question? – berndbausch Feb 20 '21 at 05:21
  • @berndbausch I have added the input in the last part of my post. I am using `curl` in `php`. The network status is `ACTIVE`. – Bani Feb 20 '21 at 05:32
  • Assuming you use `curl -X POST` and all the headers are correct, your JSON structure looks right. I wonder if you can provoke the same error with `openstack server create --image ... --network ... --flavor ... server-test`? And what do you find in the nova-api log? – berndbausch Feb 20 '21 at 05:42
  • @berndbausch I am checking the command you mentioned. As another point, my network does not have any ports. Does it cause a problem? In case I set `"networks: : "auto"` it says `'auto' is not of type 'array'`. – Bani Feb 20 '21 at 07:19
  • For `auto` you may have to explicitly set the microversion; not sure. The network doesn't need ports; the port will be created. However, you can create a port manually and specify that instead of the network's UUID. If your project has exactly one network, you can leave the network parameter out, by the way. – berndbausch Feb 20 '21 at 07:33
  • @berndbausch It works with command but it does not work via code. The nova-log says `unexpected exception in API method: ValueError: Field 'project_id' cannot be None ` – Bani Feb 20 '21 at 08:31
  • 1
    My guess: Your authentication token doesn't have a project scope. – berndbausch Feb 20 '21 at 10:21
  • @berndbausch Thank you very much indeed for your kind help. Your guess was true. – Bani Feb 20 '21 at 10:51
  • I have to say, the original error message is not just misleading, it brings us to a different dimension. But well, OpenStack has its wrinkles. – berndbausch Feb 20 '21 at 10:55

0 Answers0