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

387 views
Skip to first unread message

Lars Van Casteren

unread,
Nov 7, 2016, 9:15:59 AM11/7/16
to Ansible Project
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!

Lars Van Casteren

unread,
Nov 7, 2016, 4:32:39 PM11/7/16
to Ansible Project
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! 

misko bat

unread,
Nov 22, 2016, 12:07:15 PM11/22/16
to Ansible Project
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

Markku Tavasti

unread,
Mar 16, 2017, 7:49:50 AM3/16/17
to Ansible Project

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. 

Lucas Nunno

unread,
Apr 4, 2017, 9:45:15 AM4/4/17
to Ansible Project
@Markku Any ideas when we are not authorized to accept the image via glance?

➜ glance member-update <SHA> <NAME> accepted
403 Forbidden: You are not authorized to lookup the members of the image <SHA>. (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.

Lucas Nunno

unread,
Apr 4, 2017, 10:54:12 AM4/4/17
to Ansible Project
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''<SHA>'},
    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='<SHA>',
    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 <module>
    auto_ip=False)
  File "<decorator-gen-6>", 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)


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.

Charles Walker

unread,
Jun 21, 2017, 12:29:57 PM6/21/17
to Ansible Project
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 ?
Reply all
Reply to author
Forward
0 new messages