Resource object attribute inconsistencies via proxy interfaces

Bug #1536288 reported by Richard Theis
20
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack SDK
Fix Released
Undecided
Richard Theis

Bug Description

While investigating https://bugs.launchpad.net/python-openstacksdk/+bug/1461200, I found inconsistencies in the resource objects returned by the proxy interface methods. Take the following proxy interface example using network:

        example_network = self.conn.network.create_network(
            name='openstacksdk-example-project-network')
        print(example_network)

        for network in self.conn.network.networks():
            print(network)

        network = self.conn.network.get_network(example_network.id)
        print(network)

        network = self.conn.network.get_network(example_network)
        print(network)

        network = self.conn.network.find_network(example_network.id)
        print(network)

        network = self.conn.network.update_network(example_network.id,
                                                   admin_state_up=False)
        print(network)

        example_network.admin_state_up = False
        network = self.conn.network.update_network(example_network)
        print(network)

Looking at both resource._attrs and dir(resource) for the network resource, the following inconsistencies were noted:
1) create_network(): resource._attrs only contains the values provided via attrs parameter (i.e. name) and dir(resource) does not contain attributes for port_security_enabled, provider:network_type, provider:physical_network, provider:segmentation_id and router:external.
2) networks(): resource._attrs and dir(resource) are complete
3) get_network(): dir(resource) does not contain attributes for port_security_enabled, provider:network_type, provider:physical_network, provider:segmentation_id and router:external.
4) find_network(): Same as networks().
5) update_network(id): Same as create_network().
6) update_network(resource): Same as get_network().

Some of the resource methods appear to be missing code to update attrs based on the response data.

Update from related bug https://bugs.launchpad.net/python-openstacksdk/+bug/1474478:
I'm not sure why resource create only updates the id attribute

https://github.com/stackforge/python-openstacksdk/blob/master/openstack/resource.py#L569

Why not just grab whatever attributes are available? Might be some created_at etc type attributes to add.

Richard Theis (rtheis)
Changed in python-openstacksdk:
assignee: nobody → Richard Theis (rtheis)
Revision history for this message
Brian Curtin (brian.curtin) wrote :
Richard Theis (rtheis)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-openstacksdk (master)

Fix proposed to branch: master
Review: https://review.openstack.org/271432

Changed in python-openstacksdk:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstacksdk (master)

Reviewed: https://review.openstack.org/271432
Committed: https://git.openstack.org/cgit/openstack/python-openstacksdk/commit/?id=822f8d68ebb4d89d544c5a2a089b20d5b2d54ab9
Submitter: Jenkins
Branch: master

commit 822f8d68ebb4d89d544c5a2a089b20d5b2d54ab9
Author: Richard Theis <email address hidden>
Date: Wed Jan 20 11:55:43 2016 -0600

    Resource object attributes not updated on some interfaces

    Resource object attributes are not being updated from the REST
    API response on the create(), get() and update() interfaces.
    As a result, the resource object (self) returned may be missing
    information thus requiring an additional request to collect the
    information.

    Change-Id: I781e9eb21907d396d8ff6f55765eaca0fe3ef505
    Closes-Bug: #1536288

Changed in python-openstacksdk:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.