Home > Storage > PowerScale (Isilon) > Industry Solutions and Verticals > Media and Entertainment > PowerScale OneFS: A Metadata Driven Approach to On Demand Tiering > Get list of directories with specific DataIQ tags
The first step is to import the necessary Python modules:
import requests
import json
import urllib3
import pathlib
# Supresses the self signed cert warning
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Assumes claritynowapi has been downloaded from DataIQ host
import claritynowapi
Next the ClarityNowConnection method is called to create an object (here it is called “api”) with the necessary instance variables to connect to the DataIQ host.
api = claritynowapi.ClarityNowConnection(‘<username>’, ‘<password>’,
hostname=’<hostname or IP Address>’, port=443,
ignore_server_version=False,
override_localhost=False, enable_auth=True)
The following function accepts two variables, “tag_key” and “tag_value”. It will return a list of directories that have been tagged with the corresponding DataIQ tag. That list of directory paths is appended to a Python list called “path_series”.
Section 4 in the white paper Dell DataIQ API: Insights and Analysis thoroughly describes each line in this code. The result is a list object of paths associated with particular DataIQ tags.
def pathfinder(tag_name,tag_value):
myrequest = claritynowapi.FastStatRequest()
myrequest.resultType = claritynowapi.FastStatRequest.ALL_PATHS
mySubrequest1 = claritynowapi.SubRequest()
#Process the user input
tag1 = api.getTag(tag_name, tag_value)
#push on to the main subrequest stack a TagFilter using the tag1.id
mySubrequest1.addTagFilter (tag1.id)
myrequest.requests.append(mySubrequest1)
myresults = api.report(myrequest)
myreport = myresults.requests[0].results
path_series = []
for r in myreport:
for x in r.paths:
path_series.append(x.path)
return path_series