ContainX / openstack4j

A Fluent OpenStack SDK / Client Library for Java
http://openstack4j.com
Other
290 stars 367 forks source link

Volume snapshot object's getName() method error,return with null. but the API actually returned the name value. #1019

Closed zhoutiekui closed 7 years ago

zhoutiekui commented 7 years ago

OS4J Version: 3.0.4-snapshot

Test Code: VolumeSnapshot snapshotForce = os.blockStorage().snapshots().create(Builders.volumeSnapshot() .name(snapshotName) .volume(volume.getId()) .force(true) .build()); System.out.println("snapshot id:\t" + snapshotForce.getId()); System.out.println("snapshot name:\t" + snapshotForce.getName()); System.out.println(os.blockStorage().snapshots().get(snapshotForce.getId()).getId()); assertEquals(snapshotName, os.blockStorage().snapshots().get(snapshotForce.getId()).getName());

Output: snapshot id: 6980f66a-110d-4bcb-a7f9-eb8752395799 snapshot name: null

Analyze: the package org.openstack4j.openstack.storage.block.domain has following codes: @JsonProperty("display_name") private String name; @JsonProperty("display_description") private String description; While the API definition the name "name" not the desplay_name. The same error with the description attribute.

auhlig commented 7 years ago

Thanks for investigating @zhoutiekui. Feel encouraged to contribute a fix for that :)

cbirajdar commented 7 years ago

Hi @auhlig! I have also noticed this as an issue with CinderVolume - getName() and getDescription(). For block storage API V1, field names were display_name and display_description. Since V2, it's name and description.

@JsonRootName("volume")
public class CinderVolume implements Volume {
    @JsonProperty("display_name")
    private String name;
    @JsonProperty("display_description")
        private String description;

Is version 1 still supported for managing cinder volumes? I can simply rename these properties in CinderVolume and update V1/V2 related unit tests which would otherwise fail.

Thank you!

auhlig commented 7 years ago

This was fixed by now, wasn't it? Could you try the latest snapshot?

cbirajdar commented 7 years ago

For block storage API V2, it was fixed for CinderVolumeSnapshot but still an issue with CinderVolume. I will submit a PR to address this.