Home > Storage > PowerScale (Isilon) > Industry Solutions and Verticals > Media and Entertainment > PowerScale OneFS: A Metadata Driven Approach to On Demand Tiering > Pass a list of paths to the OneFS API to write extended attributes
Next, the list generated above (item_list) needs to be passed to the OneFS REST API. This API call will apply the tags identified in the section Get list of directories with specific DataIQ tags as extended attributes.
The first couple of bits of code initialize and authorize a connection to the OneFS cluster. The PAPI (platform API) and endpoint lines will be used later to call a SmartPoolsTree job:
# host configurations
CLUSTERIP = '<Cluster Admin IP>'
PORT=8080
USER='<username>'
PASS='<password>'
# initial request
uri = "https://%s:%s" % (CLUSTERIP, PORT)
namespace_path = uri + '/namespace'
headers = {'Content-Type': 'application/json'}
data = json.dumps({'username': USER, 'password': PASS, 'services': ['namespace', 'platform']})
papi = uri + '/platform'
endpoint = '/1/job/jobs'
# authorize with the configurations
session = requests.Session()
response = session.post(uri + "/session/1/session", data=data, headers=headers, verify=False)
session.headers['referer'] = uri
session.headers['X-CSRF-Token'] = session.cookies.get('isicsrf')
After a connection is authorized to the cluster, iterate through the item_list created above and apply the DataIQ tags as extended attributes using the REST API call. A response of 200 indicates success for each operation. The “fileexattr” variable gets updated with the tag name and tag value. The variable “fileextattr” is later inserted into the REST call along with the “item” variable which is the file or directory to which the extended attribute gets assigned. The last print statement is unnecessary, but a 200 response indicates success.
# write tag_name : tag_value as extended attribute
for item in item_list:
filexattr = json.dumps({"action" : "replace" , "attrs" : [ {"name" : tag_name, "value" : tag_value , "namespace" : "user"} ] } )
headers = {'Content-Type': 'application/json'}
response = session.put(namespace_path + '/ifs' + item + '?metadata', data=filexattr, headers=headers, verify=False)
print(response)
It is possible to verify that the DataIQ tags have been written from the OneFS CLI using the standard getextattr command. For instance, the following command shows that the file test.docx has an attribute “status” that is set to “in-progress”:
isilon# getextattr user status ./test.docx
.test.docx in-progress