NetApp / netappdvp

A Docker volume plugin for NetApp storage
96 stars 33 forks source link

Lots of nil values in VolumeList return #94

Closed frodopwns closed 7 years ago

frodopwns commented 7 years ago

Hello everyone!

I am using the go api in netappdvp/apis/ontap/ to interact with a netpp ontap api. I can list volumes, create volumes, and delete them.

Now I'd like to learn things about my volumes like space availability. I noticed there are some promising attributes in the Result that is returned from VolumeList but almost everything in there is a nil pointer. Is this expect behavior? If not can anyone point me toward a solution?

Here is a sample return from VolumeList (converted to json):

{
  "XMLName": {
    "Space": "http://www.netapp.com/filer/admin",
    "Local": "volume-attributes"
  },
  "VolumeAntivirusAttributesPtr": null,
  "VolumeAutobalanceAttributesPtr": null,
  "VolumeAutosizeAttributesPtr": null,
  "VolumeCloneAttributesPtr": null,
  "VolumeDirectoryAttributesPtr": null,
  "VolumeExportAttributesPtr": null,
  "VolumeFlexcacheAttributesPtr": null,
  "VolumeHybridCacheAttributesPtr": null,
  "VolumeIdAttributesPtr": {
    "XMLName": {
      "Space": "http://www.netapp.com/filer/admin",
      "Local": "volume-id-attributes"
    },
    "CommentPtr": null,
    "ContainingAggregateNamePtr": null,
    "ContainingAggregateUuidPtr": null,
    "CreationTimePtr": null,
    "DsidPtr": null,
    "FsidPtr": null,
    "InstanceUuidPtr": null,
    "JunctionParentNamePtr": null,
    "JunctionPathPtr": null,
    "MsidPtr": null,
    "NamePtr": "ecorson_test_volume",
    "NameOrdinalPtr": null,
    "NodePtr": null,
    "OwningVserverNamePtr": "vsvmware",
    "OwningVserverUuidPtr": null,
    "ProvenanceUuidPtr": null,
    "StylePtr": null,
    "TypePtr": null,
    "UuidPtr": null
  },
  "VolumeInfinitevolAttributesPtr": null,
  "VolumeInodeAttributesPtr": null,
  "VolumeLanguageAttributesPtr": null,
  "VolumeMirrorAttributesPtr": null,
  "VolumePerformanceAttributesPtr": null,
  "VolumeQosAttributesPtr": null,
  "VolumeSecurityAttributesPtr": null,
  "VolumeSisAttributesPtr": null,
  "VolumeSnapshotAttributesPtr": null,
  "VolumeSnapshotAutodeleteAttributesPtr": null,
  "VolumeSpaceAttributesPtr": null,
  "VolumeStateAttributesPtr": null,
  "VolumeTransitionAttributesPtr": null,
  "VolumeVmAlignAttributesPtr": null
}
frodopwns commented 7 years ago

Looks like the only attribute being requested is the name:

 <volume-get-iter>
     <desired-attributes>
         <volume-attributes>
             <volume-id-attributes>
                 <name></name>
             </volume-id-attributes>
         </volume-attributes>
     </desired-attributes>
     <max-records>4294967294</max-records>
     <query>
         <volume-attributes>
             <volume-id-attributes>
                 <name>ecorson_test_volume*</name>
             </volume-id-attributes>
         </volume-attributes>
     </query>
 </volume-get-iter>

How can I get the other attributes?

adkerr commented 7 years ago

Hi @frodopwns,

The zapi library in netappdvp isn't really designed to be used in a general purpose manor and isn't supported in such a capacity. It's a very limited subset of calls specifically tailored to netappdvp's needs.

The reason you're only getting the name back is because netappdvp only needs that field and it's puts less load on the server to filter the requests like that.

If you want to explore the API you'd be better off using the official NetApp Manageability SDK available for download at mysupport.netapp.com.

frodopwns commented 7 years ago

@adkerr

Understood. Thanks for the quick response. It does look like I can reuse some of your code and if I clone the Zapi runner I could add the attributes I'm looking for:

    queryVolIdAttrs := azgo.NewVolumeIdAttributesType().SetName(azgo.VolumeNameType(prefix + "*"))
    query := azgo.NewVolumeAttributesType().SetVolumeIdAttributes(*queryVolIdAttrs)

    // Limit the returned data to only the FlexVol names
    desiredVolIdAttrs := azgo.NewVolumeIdAttributesType().SetName("")
    VolOtheratt := azgo.NewVolumeSpaceAttributesType().SetPercentageSizeUsed(0)
    desiredAttributes := azgo.NewVolumeAttributesType().SetVolumeIdAttributes(*desiredVolIdAttrs)
    desiredAttributes.SetVolumeSpaceAttributes(*VolOtheratt)
    response, err = azgo.NewVolumeGetIterRequest().
        SetMaxRecords(maxZapiRecords). // Is there any value in iterating?
        SetQuery(*query).
        SetDesiredAttributes(*desiredAttributes).
        ExecuteUsing(d.zr)

If I use your SDK and want to use Golang, won't I still have to duplicate a lot of what you have already done here?

adkerr commented 7 years ago

Yes, unfortunately go isn't officially supported in the sdk. :(

You can also get ALL attributes by removing the desired-attributes section entirely from your request.

frodopwns commented 7 years ago

PSH, Go is the future! Thanks for that tip...will come in handy.

Is your team going to be using this library or is it going to go away?

adkerr commented 7 years ago

Afaik we're going to continue using this library for the foreseeable future

frodopwns commented 7 years ago

Awesome! I am building a POC for my company using this. I will happily chime in here if I find anything useful.

Thanks and have a great weekend!