TypeError: 'OpenStackNetwork' object does not support indexing

788 Views Asked by At

I have a function:

 node = self.conn.NodeDriver.create_node(name = utils.VM_NAME %
 (course_id, names[i], idx), 
          image = images[i], 
          size = sizes[i],
          networks = network[i], 
          ex_keyname = key_pair.name)
 self.nodes.append(node)

with networks parameter, I assign a list like this:

<OpenStackNetwork id="d271340d-a55c-4470-af22-42640072917f" name="n-89-net2" cidr="None">

when compile I get error:

    networks = network[i],
TypeError: 'OpenStackNetwork' object does not support indexing

please teach me how to fix this. thank you.

1

There are 1 best solutions below

2
On

you just assigned a single object to networks parameter, which definitely will not work, try something like [OpenStackNetwork()]

Note: put your real object instead of my example