Error in creating instance (Inner Exception: create() takes at least 4 arguments (9 given))

Hi,

I’m trying to create a vm instance via ansible on trystack. Modules such as os_network, os_subnet and os_image_facts are all working.
When trying to use os_server I get this message:

fatal: [localhost]: FAILED! => {“changed”: false, “extra_data”: null, “failed”: true, “msg”: “Error in creating instance (Inner Exception: create() takes at least 4 arguments (9 given))”}

This is the yaml:

  • name: Create a Cirros Server instance
    os_server:
    state: present
    name: server1
    image: openstack_image.id
    key_name: Key_1
    timeout: 200
    flavor: 1
    nics:
  • net-id: openstack_subnets.id
    meta:
    hostname: server1
    group: testgroup

Shade 1.12.1

Openstack: 3.3.0

Where should I start looking?

Thanks!

I managed to fix this.

I tried downgrading shade but that didn’t help, anything below 1.12.1 gave:

“msg”: “Error in creating instance (Inner Exception: Missing imageRef attribute (HTTP 400) (Request-ID: req-48b19472-b5d4-4772-8f98-47112f176592))”

In fact, with shade <1.12.1 none of the previously fetched facts included the .id value, vars like openstack_image.id were not returned.
Using shade 1.11 I tried hardcoding the subnet id & image and that worked in creating an instance.

I tried the python example from the shade readme on GitHub (https://github.com/openstack-infra/shade/blob/master/README.rst) and that worked also.

Instance got created & booted etc. Hmm

I upgraded shade back to 1.12.1 and tried again, lo and behold, it got created!

Great!

Hello,

for those who were lead to this page by Google search. If you run into messages like

“Error in creating instance (Inner Exception: create() takes at least 4 arguments (10 given))”}

or

Error in creating instance (Inner Exception: Missing imageRef attribute (HTTP 400))

Then it might help to fix python module shade/openstackcloud.py, around line 4950:

server = self.manager.submit_task(_tasks.ServerCreate(name=name, **kwargs))

add image=“something”:

server = self.manager.submit_task(_tasks.ServerCreate(name=name, image=“put-your-image-id-here”, **kwargs))

For some reason, image name is not propagated via kwargs.

Michal

maanantai 7. marraskuuta 2016 16.15.59 UTC+2 Lars Van Casteren kirjoitti:

fatal: [localhost]: FAILED! => {“changed”: false, “extra_data”: null, “failed”: true, “msg”: “Error in creating instance (Inner Exception: create() takes at least 4 arguments (9 given))”}

I got this error when image was shared from other project with ‘glance member-create’ but that was not accepted. ‘nova image-list’ showed image, glance image-list not.
After ‘glance member-update’ everything works.

@Markku Any ideas when we are not authorized to accept the image via glance?

➜ glance member-update accepted
403 Forbidden: You are not authorized to lookup the members of the image . (HTTP 403)

I’m seeing the same issue as the parent post. Updating the code by hand does work i.e. what Michal posted, but I’d like to use that as a last resort.

If I do something like

#!/usr/bin/env python

import shade

Initialize and turn on debug logging

shade.simple_logging(debug=True)

cloud = shade.openstack_cloud()

cloud.create_server(
name=‘my-server’,
image={‘id’: ‘’},
key_name=‘mykey’,
availability_zone=‘my-avail-zone’,
flavor=‘m1.medium’,
auto_ip=False)

That works as expected but if I do

#!/usr/bin/env python

import shade

Initialize and turn on debug logging

shade.simple_logging(debug=True)

cloud = shade.openstack_cloud()

cloud.create_server(
name=‘my-server’,
image=‘’,
key_name=‘mykey’,
availability_zone=‘my-avail-zone’,
flavor=‘m1.medium’,
auto_ip=False)

I get the following stack trace

Traceback (most recent call last):
File “./make_vm_images.py”, line 16, in
auto_ip=False)
File “”, line 2, in create_server
File “/opt/miniconda/envs/ansible/lib/python2.7/site-packages/shade/_utils.py”, line 393, in func_wrapper
return func(*args, **kwargs)
File “/opt/miniconda/envs/ansible/lib/python2.7/site-packages/shade/openstackcloud.py”, line 5510, in create_server
“Error in creating the server.”)
File “/opt/miniconda/envs/ansible/lib/python2.7/contextlib.py”, line 35, in exit
self.gen.throw(type, value, traceback)
File “/opt/miniconda/envs/ansible/lib/python2.7/site-packages/shade/_utils.py”, line 461, in shade_exceptions
raise exc.OpenStackCloudBadRequest(error_message)

I’m guessing that it’s hitting the lines here: https://github.com/openstack-infra/shade/blob/master/shade/openstackcloud.py#L5477-L5481

And when it’s not a dict it tries doing an image lookup which fails because the image is a shared image and not a project image. I’m wondering if there’s any way to force ansible to pass in image as a dict I tried constructing the image YAML as an object but that fails as well.

I m having a similar issue on my side with ansible failling to create an instance based on a “shared” image. Same error message: “Inner Exception: Invalid imageRef provided.”

If we accept the image it will works fine but it is extra works for us and we are not facing the issue when we deploy with Terraform so I m wondering if there was an ongoing action to change this behavior and having ansible able to use shared image ?