Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of EStructuralFeatures and AttributeStates in MixinBases #62

Open
kortef opened this issue Apr 16, 2018 · 2 comments
Labels

Comments

@kortef
Copy link

kortef commented Apr 16, 2018

There exist an inconsistency with handling the AttributeStates in the code, which is due to the fact that their values can be stored in two places:

  1. The EStructuralFeatures of the MixinBases
  2. The AttributeState list of the MixinBases

Ideally, these two things should be synchronized and calls to the corresponding getters and setters should yield the same values.

Consider the example below (which is part of a NetworkInterfaceConnector generated with help of OCCIware Studio, slightly modified to fit this issue report):

public void occiRetrieve()
{
        LOGGER.debug("occiRetrieve() called on " + this);
        ...       
        port = os.networking().port().get(port.getId());
        ...       
        // Update IP address
        for (MixinBase mixin: this.getParts()) {
                // find corresponding mixinbase
                if (mixin instanceof Ipnetworkinterface) {
                        LOGGER.debug("Associated port has IP: "
                        + port.getIP();
                        // set the attribute accordingly
                        OcciHelper.setAttribute(mixin,
                        "occi.networkinterface.address", port.getIP())
                }
        }
               
        for (AttributeState state: this.getAttributes()) {
                LOGGER.info(state.getName() + ": " + state.getValue());
        }      
}

Executing this code with the MartServer gives:

2018-03-14 13:38:57.270 INFO occi.core.id:
4ab430ad-da63-483c-8f50-9abbf056da26
2018-03-14 13:38:57.270 INFO occi.core.title: link1
2018-03-14 13:38:57.270 INFO occi.networkinterface.interface:
2018-03-14 13:38:57.270 INFO occi.networkinterface.mac:
2018-03-14 13:38:57.270 INFO occi.networkinterface.state: active
2018-03-14 13:38:57.270 INFO occi.networkinterface.state.message:
2018-03-14 13:38:57.270 INFO occi.networkinterface.address:
2018-03-14 13:38:57.270 INFO occi.networkinterface.gateway:
2018-03-14 13:38:57.270 INFO occi.networkinterface.allocation: dynamic
2018-03-14 13:38:57.270 WARN Attributes retrieves on mixin :
org.modmacao.openstack.connector.IpnetworkinterfaceConnector@87929e2
(occiNetworkinterfaceAddress: 10.0.0.6, occiNetworkinterfaceGateway:
null, occiNetworkinterfaceAllocation: dynamic) --> []

Here the part

occi.networkinterface.address:

should be

occi.networkinterface.address: 10.0.0.6

Obviously, the IP address is set correctly in the Mixin, but not in the
AttributeState of the NetworkInterface.

@kortef
Copy link
Author

kortef commented Apr 16, 2018

I discovered that the different methods to retrieve and set AttributeStates show the following behaviour, which leads to the problem mentioned in the issue above:

OCCIHelper.setAttribute(MixinBase mixinBase, String attributeName, String attributeValue):

Sets the value of the EStructuralFeature, IF it exists, ELSE a corresponding AttributeState is set.

MixinBase.getAttributes():
Returns a list of the AttributeStates, NOT synchronized with the values of the EStructuralFeatures.

Maybe, I am using the methods in a way which is not intended, so the question for me is: What is the indented behaviour?
Should the synchronization be left to the user or is that something which could be provided by the OCCIHelper, e.g. it could offer a method
OCCIHelper.getAttributeValue(MixinBase mixinBase, String attributeName) which returns the corresponding value regardless of if it is stored in an AttributeState or an EStructuralFeature. In case, this method is implemented, maybe the old method OCCIHelper.getAttribute(MixinBase mixinBase, ...) should be renamed to OCCIHelper.getAttributeValue(MixinBase mixinBase, ...) to be consistent.

Another solution could be to change the behaviour of OCCIHelper.setAttribute(...) such that it always sets the value of the AttributeState AND the EStructuralFeature. Of course this would be a waste of resources.

@cgourdin
Copy link
Member

Hello, thank you for the report, we will update the project accordingly. This is clearly a bug.

@cgourdin cgourdin added the bug label Apr 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants