def create_snapshot() -> None: """Create snapshot """ print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Snapshots need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) print() snapshot_name = input("Enter the name of the snapshot to be created:-") snapshot = Snapshot.from_dict({ 'name': snapshot_name, 'volume.uuid': vol_uuid }) try: if snapshot.post(poll=True): print("Snapshot %s created Successfully" % snapshot.name) except NetAppRestError as error: print("Exception caught :" + str(error))
def delete_snapshot() -> None: """Delete Snapshot""" print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Snapshots need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) show_snapshot(svm_name, volume_name) print() snapshotname = input( "Enter the name of the snapshot that needs to be Deleted:- ") try: snapshot = Snapshot.find(vol_uuid, name=snapshotname) except NetAppRestError as error: print("Exception caught :" + str(error)) try: if snapshot.delete(poll=True): print("Snapshot %s has been deleted Successfully." % snapshot.name) except NetAppRestError as error: print("Exception caught :" + str(error))
def list_qtree(): """List Qtrees in a Volume""" print() print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Qtrees need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) print() print("The List of Qtrees:-") print("====================") try: for qtree in Qtree.get_collection(**{"volume.uuid": vol_uuid}): print("Name:- %s ID:- %s" % (qtree.name, qtree.id)) except NetAppRestError as error: print("Exception caught :" + str(error)) return vol_uuid
def delete_qtree() -> None: """Delete Qtree""" print("=============================================") print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Snapshots need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) show_qtree(svm_name, volume_name) print() print("=============================================") print("Enter the following details to Delete a qtree") qtree_name = input("Enter the Name of the Qtree to be Deleted:-") try: qtree = Qtree.find(vol_uuid, name=qtree_name) except NetAppRestError as error: print("Exception caught :" + str(error)) try: if qtree.delete(poll=True): print("Qtree %s has been deleted Successfully." % qtree.name) except NetAppRestError as error: print("Exception caught :" + str(error))
def patch_snapshot() -> None: """Update Snapshot""" print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Snapshots need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) show_snapshot(svm_name, volume_name) print() snapshot_name = input("Enter the name of the snapshot to be updated:-") snapshot = Snapshot.find(vol_uuid, name=snapshot_name) snapbool = input("Would you like to update the name (y/n): ") if snapbool == 'y': snapname = input("Enter the name of the snapshot to be updated:-") snapshot.name = snapname combool = input("Would you like to update the comment (y/n): ") if combool == 'y': snapcom = input("Enter the comment of the snapshot to be updated:-") snapshot.comment = snapcom expirybool = input("Would you like to update the expiry date (y/n): ") if expirybool == 'y': snapexpiry = input( "Enter the expiry date of the snapshot to be updated (format:- 2019-02-04T19:00:00Z):-" ) snapshot.expiry_time = snapexpiry try: if snapshot.patch(poll=True): print("Snapshot %s Updated Successfully" % snapshot.name) except NetAppRestError as error: print("Exception caught :" + str(error))
def patch_qtree() -> None: """Update Qtree""" print("=============================================") print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Snapshots need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) show_qtree(svm_name, volume_name) print() print("=============================================") print("Enter the following details to Update a qtree") qtree_name = input("Enter the Name of the Qtree to be updated:-") try: qtree = Qtree.find(vol_uuid, name=qtree_name) except NetAppRestError as error: print("Exception caught :" + str(error)) nambool = input("Would you like to update the Qtree name (y/n): ") if nambool == 'y': qtreename = input("Enter the name of the qtree to be updated:-") qtree.name = qtreename try: if qtree.patch(poll=True): print("Qtree %s Updated Successfully" % qtree.name) except NetAppRestError as error: print("Exception caught :" + str(error))
def list_snapshot() -> None: """List Snapshots in a volume""" print() print("The List of SVMs:-") show_svm() print() svm_name = input( "Enter the SVM from which the Volumes need to be listed:-") print() show_volume(svm_name) print() volume_name = input( "Enter the Volume from which the Snapshots need to be listed:-") print() vol_uuid = get_key_volume(svm_name, volume_name) print() print("The List of Snapshots:-") print("=======================") try: for snapshot in Snapshot.get_collection(vol_uuid): print(snapshot.name) except NetAppRestError as error: print("Exception caught :" + str(error))