Exemple #1
0
def create_qtree_pycl(volume_name: str, vserver_name: str,
                      qtree_name: str) -> None:
    """Creates a new quota tree in a volume"""

    data = {
        'name': qtree_name,
        'volume': {
            'name': volume_name
        },
        'svm': {
            'name': vserver_name
        },
        'security_style': 'unix',
        'unix_permissions': 744,
        'export_policy_name': 'default',
        'qos_policy': {
            'max_throughput_ops': 1000
        }
    }
    qtree = Qtree(**data)
    try:
        qtree.post()
        print("Qtree %s created successfully" % qtree.name)
    except NetAppRestError as err:
        print("Error: QTree was not created: %s" % err)
    return
def create_qtree() -> None:
    """Create qtrees"""
    print()
    print("The List of SVMs")
    print("================")
    show_svm()
    print()
    svm_name = input(
        "Enter the SVM Name on which the qtree need to be created:-")
    print()
    show_volume(svm_name)
    print()
    vol_name = input(
        "Enter the Volume Name on which the Qtree need to be created:-")

    print()
    qtree_name = input("Enter the name of the Qtree to be created:-")

    qtree = Qtree.from_dict({
        'name': qtree_name,
        'volume.name': vol_name,
        'svm.name': svm_name
    })

    try:
        if qtree.post(poll=True):
            print("Qtree  %s created Successfully" % qtree.name)
    except NetAppRestError as error:
        print("Error:- " % error.http_err_response.http_response.text)
        print("Exception caught :" + str(error))
def patch_qtree() -> None:
    """Update Qtree"""
    print("=============================================")
    print()
    vol_uuid = show_qtree()

    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("Error:- " % error.http_err_response.http_response.text)
        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("Error:- " % error.http_err_response.http_response.text)
        print("Exception caught :" + str(error))
Exemple #4
0
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
Exemple #5
0
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))
Exemple #6
0
def show_qtree(svm_name, volume_name) -> None:
    """List Qtrees in a Volume"""
    vol_uuid = get_key_volume(svm_name, volume_name)
    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("Error:- " % error.http_err_response.http_response.text)
        print("Exception caught :" + str(error))
Exemple #7
0
def create_qtree(qtree_name: str, volume_name: str, vserver_name: str) -> None:
    """Creates a new volume in a SVM"""
    print("Creating QTree...")
    data = {
        "name": qtree_name,
        "svm": {
            "name": vserver_name
        },
        "volume": {
            "name": volume_name
        }
    }

    qtree = Qtree(**data)

    try:
        qtree.post()
        print("qtree %s created successfully" % qtree.name)
    except NetAppRestError as err:
        print("qtree create: %s" % err)
    return
Exemple #8
0
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 delete_qtree() -> None:
    """Delete Qtree"""
    print("=============================================")
    print()
    vol_uuid = show_qtree()
    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("Error:- " % error.http_err_response.http_response.text)
        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("Error:- " % error.http_err_response.http_response.text)
        print("Exception caught :" + str(error))
Exemple #10
0
### Step 1 - Read in global variables
with open(os.path.dirname(sys.argv[0]) + '/../global.vars') as json_file:
    global_vars = json.load(json_file)

### Step 2 - Configure connection
config.CONNECTION = HostConnection(global_vars["PRI_CLU"],
                                   username=global_vars["PRI_CLU_USER"],
                                   password=global_vars["PRI_CLU_PASS"],
                                   verify=False)

### Step 3 - Create operation
# execute create operation
qtree = Qtree.from_dict({
    "name": "cifs_01",
    "svm": {
        "name": global_vars["PRI_SVM"]
    },
    "volume": {
        "name": global_vars["PRI_SVM"] + "_cifs_01"
    },
    "security_style": "ntfs"
})

print("--> Starting qtree create operation")
try:
    qtree.post()
    print("--> Qtree \"{}\" created successfully".format(qtree.name))
except NetAppRestError as err:
    print("--> Error: SVM was not created:\n{}".format(err))
print("")
### Step 3 - Get & print details
# Volumes
print("--> Printing volume details")
print("{:<20}{:<25}{:<15}{:<15}".format("SVM", "Name", "Size", "Used"))
for volume in Volume.get_collection():
    volume.get()
    print("{:<20}{:<25}{:<15}{:<15}".format(volume.svm.name, volume.name,
                                            volume.size, volume.space.used))
print("")

# Qtrees
print("--> Printing qtree details")
print("{:<20}{:<10}{:<15}{:<35}".format("SVM", "Style", "Export Policy",
                                        "Path"))
for qtree in Qtree.get_collection():
    qtree.get()
    print("{:<20}{:<10}{:<15}{:<35}".format(qtree.svm.name,
                                            qtree.security_style,
                                            qtree.export_policy.name,
                                            qtree.path))
print("")

# CIFS Shares
print("--> Printing CIFS share details")
print("{:<20}{:<15}{:<35}".format("SVM", "Share", "Path"))
for cifsshare in CifsShare.get_collection():
    cifsshare.get()
    print("{:<20}{:<15}{:<35}".format(cifsshare.svm.name, cifsshare.name,
                                      cifsshare.path))
print("")