Skip to content

Commit

Permalink
Isilon_Tools Version 3.1
Browse files Browse the repository at this point in the history
Adding support to OneFS 7.2
** Bug Fixes
  • Loading branch information
obergt committed Apr 27, 2015
1 parent 8643cbc commit d16dc7c
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 48 deletions.
Binary file added Read Me v3.docx
Binary file not shown.
Binary file added Read Me.docx
Binary file not shown.
131 changes: 83 additions & 48 deletions isilon/platform.py
Expand Up @@ -35,55 +35,80 @@ def get_object(self, type):
objects = ""
count = 0
resume = None
while True:
if type == 'shares':
if resume == None:
r = self.api_call("GET", self.platform_url + "/protocols/smb/shares")
else:
r = self.api_call("GET", self.platform_url + "/protocols/smb/shares?resume="+resume)
elif type == 'exports':
if resume == None:
r = self.api_call("GET", self.platform_url + "/protocols/nfs/exports")
else:
r = self.api_call("GET", self.platform_url + "/protocols/nfs/exports?resume="+resume)
elif type == 'quotas':
if resume == None:
r = self.api_call("GET", self.platform_url + "/quota/quotas/")
else:
r = self.api_call("GET", self.platform_url + "/quota/quotas?resume="+resume)
r = self.api_call("GET", self.platform_url + "/zones")
data = r.json()
zones = ""
for obj in data['zones']:
if zones == "":
zones = obj['zone_id'], obj['name']
else:
self.log.exception("illegal type!")
data = r.json()
for obj in data[type]:
objects += str(json.dumps(obj)) + "\n"
zones = zones, (obj['zone_id'], obj['name'])
for zone in zones:
while True:
if type == 'shares':
self.log.log(logging.INFO,"Backing up share on path %s description: %s",obj['path'], obj['description'])
if type == 'exports':
for tmp in obj['paths']:
self.log.log(logging.INFO,"Backing up exports on path %s description: %s", tmp, obj['description'])
if type == 'quotas':
self.log.log(logging.INFO,"Backing up quota on path %s type: %s", obj['path'], obj['type'])
count += 1
resume = data['resume']
if resume == None:
break
if resume == None:
r = self.api_call("GET", self.platform_url + "/protocols/smb/shares?zone="+zone[1])
else:
r = self.api_call("GET", self.platform_url + "/protocols/smb/shares?zone="+zone[1]+"&resume="+resume)
elif type == 'exports':
if resume == None:
r = self.api_call("GET", self.platform_url + "/protocols/nfs/exports?zone="+zone[1])
else:
r = self.api_call("GET", self.platform_url + "/protocols/nfs/exports?zone="+zone[1]+"&resume="+resume)
elif type == 'quotas':
if resume == None:
r = self.api_call("GET", self.platform_url + "/quota/quotas/")
else:
r = self.api_call("GET", self.platform_url + "/quota/quotas?resume="+resume)
else:
self.log.exception("illegal type!")
data = r.json()
for obj in data[type]:
if type == 'exports':
obj['zid'] = zone[0]
objects += str(json.dumps(obj)) + "\n"
if type == 'shares':
self.log.log(logging.INFO,"Backing up share on path %s description: %s",obj['path'], obj['description'])
if type == 'exports':
for tmp in obj['paths']:
self.log.log(logging.INFO,"Backing up exports on path %s description: %s", tmp, obj['description'])
if type == 'quotas':
self.log.log(logging.INFO,"Backing up quota on path %s type: %s", obj['path'], obj['type'])
count += 1
resume = data['resume']
if resume == None:
break
if type in data:
return objects, count
return None

def set_object(self, obj, type):
r = self.api_call("GET", self.platform_url + "/zones")
data = r.json()
zones = ""
for zone in data['zones']:
if zones == "":
zones = zone['zone_id'], zone['name']
else:
zones = zones, (zone['zone_id'], zone['name'])
if type == 'shares':
del obj['id']
zid = obj['zid']
del obj['zid']
params = json.dumps(obj)
r = self.api_call("POST", self.platform_url + "/protocols/smb/shares", data=params)
r = self.api_call("POST", self.platform_url + "/protocols/smb/shares?zone="+zones[(int(zid)-1)][1], data=params)
elif type == 'exports':
del obj['id']
del obj['time_delta']
del obj['unresolved_clients']
del obj['conflicting_paths']
del obj['map_all']
zid = obj['zid']
del obj['zid']
if obj['snapshot'] == '-':
del obj['snapshot']
params = json.dumps(obj)
r = self.api_call("POST", self.platform_url + "/protocols/nfs/exports", data=params)
r = self.api_call("POST", self.platform_url + "/protocols/nfs/exports?zone="+zones[(int(zid)-1)][1], data=params)
elif type == 'quotas':
del obj['usage']
del obj['linked']
Expand All @@ -101,23 +126,33 @@ def set_object(self, obj, type):
return

def delete_object(self, type):
if type == 'shares':
self.log.log(logging.INFO,"Lists all the shares from the Isilon..")
r = self.api_call("GET", self.platform_url + "/protocols/smb/shares/")
if type == 'quotas':
r = self.api_call("DELETE", self.platform_url + "/quota/quotas/")
self.log.log(logging.INFO, "Deleting all quotas")
else:
r = self.api_call("GET", self.platform_url + "/zones")
data = r.json()
for item in data[type]:
self.log.log(logging.INFO, "Deleting share "+item['name'])
r = self.api_call("DELETE", self.platform_url + "/protocols/smb/shares/"+item['name'])
zones = ""
for zone in data['zones']:
if zones == "":
zones = zone['zone_id'], zone['name']
else:
zones = zones, (zone['zone_id'], zone['name'])
for zone in zones:
if type == 'shares':
self.log.log(logging.INFO,"Lists all the shares from access zone "+zone[1])
r = self.api_call("GET", self.platform_url + "/protocols/smb/shares?zone="+zone[1])
data = r.json()
for item in data[type]:
self.log.log(logging.INFO, "Deleting share "+item['name'])
r = self.api_call("DELETE", self.platform_url + "/protocols/smb/shares/"+item['name']+"?zone="+zone[1])
elif type == 'exports':
self.log.log(logging.INFO,"Lists all the exports from access zone "+zone[1])

elif type == 'exports':
self.log.log(logging.INFO,"Lists all the exports from the Isilon..")
r = self.api_call("GET", self.platform_url + "/protocols/nfs/exports/")
data = r.json()
for item in data[type]:
self.log.log(logging.INFO, "Deleting export ID: "+str(item['id']))
r = self.api_call("DELETE", self.platform_url + "/protocols/nfs/exports/"+str(item['id']))
r = self.api_call("GET", self.platform_url + "/protocols/nfs/exports?zone="+zone[1])
data = r.json()
for item in data[type]:
self.log.log(logging.INFO, "Deleting export ID: "+str(item['id']))
r = self.api_call("DELETE", self.platform_url + "/protocols/nfs/exports/"+str(item['id'])+"?zone="+zone[1])

elif type == 'quotas':
r = self.api_call("DELETE", self.platform_url + "/quota/quotas/")
self.log.log(logging.INFO, "Deleting all quotas")
return
9 changes: 9 additions & 0 deletions isilon/requests/.idea/requests.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions isilon/session.py
Expand Up @@ -89,6 +89,7 @@ def api_call(self, method, urlext, **kwargs):

if r.status_code == 404:
self.log.log(logging.ERROR, "Object not found!")
print r.text
raise ObjectNotFound()
elif r.status_code == 401:
self.log_api_call(r, logging.ERROR)
Expand Down

0 comments on commit d16dc7c

Please sign in to comment.