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

**URL:** <https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970>\
**Category:** Ansible Project\
**Created:** [November 6, 2016, 10:49pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970 "2016-11-06T22:49:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Van\_Casteren](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lars\_Van\_Casteren](https://forum.ansible.com/u/Lars_Van_Casteren)\
**Post date:** [November 6, 2016, 10:49pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/1 "2016-11-06T22:49:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Lars\_Van\_Casteren](https://avatars.discourse-cdn.com/v4/letter/l/bb73d2/32.png) [@Lars\_Van\_Casteren](https://forum.ansible.com/u/Lars_Van_Casteren)\
**Post date:** [November 7, 2016, 9:32pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/2 "2016-11-07T21:32:39Z")

</div>

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](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!

---

<div class="post-metadata">

**Author:** ![misko\_bat](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@misko\_bat](https://forum.ansible.com/u/misko_bat)\
**Post date:** [November 20, 2016, 1:51pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/3 "2016-11-20T13:51:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Markku\_Tavasti](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Markku\_Tavasti](https://forum.ansible.com/u/Markku_Tavasti)\
**Post date:** [March 16, 2017, 11:30am UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/4 "2017-03-16T11:30:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Lucas\_Nunno](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Lucas\_Nunno](https://forum.ansible.com/u/Lucas_Nunno)\
**Post date:** [April 3, 2017, 11:18pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/5 "2017-04-03T23:18:47Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![Lucas\_Nunno](https://avatars.discourse-cdn.com/v4/letter/l/bcef8e/32.png) [@Lucas\_Nunno](https://forum.ansible.com/u/Lucas_Nunno)\
**Post date:** [April 4, 2017, 2:54pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/6 "2017-04-04T14:54:11Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Charles\_Walker](https://avatars.discourse-cdn.com/v4/letter/c/e9bcb4/32.png) [@Charles\_Walker](https://forum.ansible.com/u/Charles_Walker)\
**Post date:** [June 21, 2017, 2:38pm UTC](https://forum.ansible.com/t/error-in-creating-instance-inner-exception-create-takes-at-least-4-arguments-9-given/22970/7 "2017-06-21T14:38:41Z")

</div>

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 ?
