def list_lun(): """ List LUN""" print("\n List of LUN:- \n") try: for lun in Lun.get_collection(): print("Lun Name:- %s; Lun UUID:- %s " % (lun.name, lun.uuid)) except NetAppRestError as error: print("Exception caught :" + str(error))
def show_lun() -> None: """ List LUN""" print("\n List of LUN:- \n") try: for lun in Lun.get_collection(): print("Lun Name:- %s; Lun UUID:- %s " % (lun.name, lun.uuid)) except NetAppRestError as error: print("Error:- " % error.http_err_response.http_response.text) print("Exception caught :" + str(error))
def delete_lun() -> None: """ Delete Lun""" print("----------Delete Lun-----------") print() show_lun() lun_name = input("Enter the name of the LUN :- ") try: lun = Lun.find(name=lun_name) if lun.delete(poll=True): print("LUN deleted successfully.") except NetAppRestError as error: print("Exception caught :" + str(error))
def patch_lun() -> None: """ Patch lun""" print("----------Patch Interface-----------") print() show_lun() lun_name = input("Enter the name of the LUN :- ") lun_new_name = input("Enter the new name of the LUN to be updated :- ") try: lun = Lun.find(name=lun_name) lun.name = lun_new_name if lun.patch(poll=True): print("LUN updated successfully.") except NetAppRestError as error: print("Exception caught :" + str(error))
def create_lun(): """Create Interface""" print() show_svm() print() svm_name = input( "Enter the name of the SVM on which the interface should be created :- " ) print() show_volume(svm_name) print() vol_name = input( "Choose the volume on which you would like to create the LUN : ") print() lun_name = input("Enter the name of the LUN : ") lun_name_ext = "/vol/" + vol_name + "/" + lun_name os_type = input("Enter the name of the OS-TYPE : ") lun_size = input("Enter the LUN size in MBs :") l_size = get_size(lun_size) payload2 = { "comment": lun_name, "location": { "logical_unit": lun_name, "volume": { "name": vol_name } }, "name": lun_name_ext, "os_type": os_type, "space": { "guarantee": { "requested": bool("") }, "size": l_size }, "svm": { "name": svm_name } } lun_object = Lun.from_dict(payload2) try: if lun_object.post(poll=True): print("LUN created %s created Successfully" % lun_object.name) except NetAppRestError as error: print("Exception caught :" + str(error))
def iscsi_setup() -> None: """ Script demostrates the ISCSI Lun Setup""" print( "THE FOLLOWING SCRIPT DEMOSTRATES ISCSI LUN SETUP USING REST API PCL.") print( "====================================================================") print() show_svm() print() svm_name = input( "Choose the SVM on which you would like to create a lun : ") print( "Make sure that ISCSI protocol and LIFs on each nodes are created on the SVM" ) print() volbool = input("Would you like to create a new volume (y/n) :-") if volbool == 'y': vol_name = input("Enter the Volume Name:-") vol_size = input("Enter the Volume Size (MBs):-") aggr_name = input("Enter the aggregate name:-") v_size = get_size(vol_size) payload1 = { "name": vol_name, "svm": { "name": svm_name }, "aggregates": [{ "name": aggr_name }], "size": v_size } print(payload1) volume = Volume.from_dict(payload1) try: if volume.post(poll=True): print("Volume created created Successfully") except NetAppRestError as error: print("Error:- " % error.http_err_response.http_response.text) print("Exception caught :" + str(error)) else: print() show_volume(svm_name) vol_name = input( "Choose the volume on which you would like to create the LUN : ") print() lun_name = input("Enter the name of the LUN : ") lun_name_ext = "/vol/" + vol_name + "/" + lun_name os_type = input("Enter the name of the OS-TYPE : ") lun_size = input("Enter the LUN size in MBs :") l_size = get_size(lun_size) payload2 = { "comment": lun_name, "location": { "logical_unit": lun_name, "volume": { "name": vol_name } }, "name": lun_name_ext, "os_type": os_type, "space": { "guarantee": { "requested": bool("") }, "size": l_size }, "svm": { "name": svm_name } } lun_object = Lun.from_dict(payload2) try: if lun_object.post(poll=True): print("LUN created %s created Successfully" % lun_object.name) except NetAppRestError as error: print("Error:- " % error.http_err_response.http_response.text) print("Exception caught :" + str(error)) print() igroup_name = input( "Enter the name of the Igroup that you would like to create : ") initiator_name = input( "Enter the name of the Initiator that you would like to add in the InitiatorGroup :" ) os_type2 = input("Enter the OS-TYPE :") payload3 = { "initiators": [{ "name": initiator_name }], "name": igroup_name, "os_type": os_type2, "svm": { "name": svm_name } } igroup_object = Igroup.from_dict(payload3) try: if igroup_object.post(poll=True): print("IGROUP created %s created Successfully" % igroup_object.name) except NetAppRestError as error: print("Error:- " % error.http_err_response.http_response.text) print("Exception caught :" + str(error)) payload4 = { "igroup": { "name": igroup_name }, "lun": { "name": lun_name_ext }, "svm": { "name": svm_name } } lunmap_object = LunMap.from_dict(payload4) try: if lunmap_object.post(poll=True): print("Mapping created Successfully") except NetAppRestError as error: print("Error:- " % error.http_err_response.http_response.text) print("Exception caught :" + str(error))