def create_interface(cluster: str, headers_inc: str):
    """Create Interface"""
    int_name = input("Enter the name of the Interface:- ")
    print()
    show_svm(cluster, headers_inc)
    print()
    svm_name = input(
        "Enter the name of the SVM on which the interface should be created :- "
    )
    svm_uuid = get_key_svms(svm_name, cluster, headers_inc)
    print()
    show_node(cluster, headers_inc)
    print()
    node_name = input(
        "Enter the name of the home node on which the interface should be created :- "
    )
    node_uuid = input(
        "Enter the uuid of the home node on which the interface should be created :- "
    )
    ip_add = input("Enter the IP address:- ")
    netmask = input("Enter the NetMask:- ")

    interfaceobj = {
        "enabled": True,
        "ip": {
            "address": ip_add,
            "netmask": netmask
        },
        "name": int_name,
        "scope": "svm",
        "svm": {
            "name": svm_name,
            "uuid": svm_uuid
        },
        "location": {
            "home_node": {
                "name": node_name,
                "uuid": node_uuid
            }
        }
    }
    url = "https://{}/api/network/ip/interfaces".format(cluster)
    try:
        response = requests.post(url,
                                 headers=headers_inc,
                                 json=interfaceobj,
                                 verify=False)
    except requests.exceptions.HTTPError as err:
        print(str(err))
        sys.exit(1)
    except requests.exceptions.RequestException as err:
        print(str(err))
        sys.exit(1)
    url_text = response.json()
    if 'error' in url_text:
        print(url_text)
        sys.exit(1)
    print("Interface created successfully...")
Ejemplo n.º 2
0
def create_aggregate(cluster: str, headers_inc: str) -> None:
    """ Create aggregate"""
    print("----------Create Aggregate-----------")
    print()
    show_node(cluster, headers_inc)
    node_name = input("Enter the name of the node name :- ")
    node_uuid = input("Enter the name of the node uuid :- ")
    print()
    show_disk(cluster, headers_inc)
    aggr_name = input("Enter the name of the Aggregate :- ")
    disk_count = input("Enter the Disk Count :- ")
    raid_size = input("Enter the RAID size :- ")
    raid_type = input("Enter the RAID type :- ")

    aggrobj = {
        "block_storage": {
            "mirror": {
                "enabled": False
            },
            "primary": {
                "checksum_style": "block",
                "disk_class": "performance",
                "disk_count": disk_count,
                "raid_size": raid_size,
                "raid_type": raid_type
            }
        },
        "name": aggr_name,
        "node": {
            "name": node_name,
            "uuid": node_uuid
        },
        "snaplock_type": "non_snaplock"
    }

    url = "https://{}/api/storage/aggregates".format(cluster)
    try:
        response = requests.post(url,
                                 headers=headers_inc,
                                 json=aggrobj,
                                 verify=False)
    except requests.exceptions.HTTPError as err:
        print(err)
        sys.exit(1)
    except requests.exceptions.RequestException as err:
        print(err)
        sys.exit(1)
    url_text = response.json()
    if 'error' in url_text:
        print(url_text)
        sys.exit(1)

    print(response)
    print(" Aggregate creation completed. ")
Ejemplo n.º 3
0
def create_interface():
    """Create Interface"""
    int_name = input("Enter the name of the Interface:- ")
    print()
    show_svm()
    print()
    svm_name = input(
        "Enter the name of the SVM on which the interface should be created :- "
    )
    svm_uuid = input(
        "Enter the UUID of the SVM on which the interface should be created :- "
    )
    print()
    show_node()
    print()
    node_name = input(
        "Enter the name of the home node on which the interface should be created :- "
    )
    node_uuid = input(
        "Enter the uuid of the home node on which the interface should be created :- "
    )
    ip_add = input("Enter the IP address:- ")
    netmask = input("Enter the NetMask:- ")

    interfaceobj = {
        "enabled": True,
        "ip": {
            "address": ip_add,
            "netmask": netmask
        },
        "name": int_name,
        "scope": "svm",
        "svm": {
            "name": svm_name,
            "uuid": svm_uuid
        },
        "location": {
            "home_node": {
                "name": node_name,
                "uuid": node_uuid
            }
        }
    }
    try:
        ipint = IpInterface.from_dict(interfaceobj)
        if ipint.post(poll=True):
            print("Interface created successfully.")
    except NetAppRestError as error:
        print("Exception caught :" + str(error))
def create_aggregate() -> None:
    """ Create aggregate"""
    print("----------Create Aggregate-----------")
    print()
    show_node()
    node_name = input("Enter the name of the node name :- ")
    node_uuid = input("Enter the name of the node uuid :- ")
    print()
    show_disk()
    aggr_name = input("Enter the name of the Aggregate :- ")
    disk_count = input("Enter the Disk Count :- ")
    raid_size = input("Enter the RAID size :- ")
    raid_type = input("Enter the RAID type :- ")

    aggrobj = {
        "block_storage": {
            "mirror": {
                "enabled": "false"
            },
            "primary": {
                "checksum_style": "block",
                "disk_class": "performance",
                "disk_count": disk_count,
                "raid_size": raid_size,
                "raid_type": raid_type
            }
        },
        "name": aggr_name,
        "node": {
            "name": node_name,
            "uuid": node_uuid
        },
        "snaplock_type": "non_snaplock"
    }

    try:
        aggr = Aggregate.from_dict(aggrobj)
        if aggr.post(poll=True):
            print("Aggregate created successfully.")
    except NetAppRestError as error:
        print("Exception caught :" + str(error))
Ejemplo n.º 5
0
def create_svm(cluster: str, headers_inc: str):
    """ create svm"""
    svmname = input("Enter the name of the SVM: ")
    dataobj = {}
    dataobj['name'] = svmname
    dataobj['language'] = "c.utf_8"
    ipspaceobj = {"name": "Default"}
    dataobj['ipspace'] = ipspaceobj
    print()
    intbool = input("Would you like to configure an Interface (y/n): ")
    if intbool == 'y':
        mgmtlif = input("Enter the name of Management LIF: ")
        ipadd = input("Enter the IP address: ")
        nmask = input("Enter the NetMask: ")
        show_node(cluster, headers_inc)
        hnode = input("Enter the Home Node: ")
        uuid = input("Enter the UUID: ")
        intjson = [{
            "ip": {
                "address": ipadd,
                "netmask": nmask
            },
            "location": {
                "broadcast_domain": {
                    "name":
                    "Default_ckjfbvsnkfdjasbdkfsndlfe_cbekjrvckujeakbxjwc"
                },
                "home_node": {
                    "name": hnode,
                    "uuid": uuid
                }
            },
            "name": mgmtlif,
            "service_policy": "default-data-files"
        }]
        dataobj['ip_interfaces'] = intjson
    print()
    nfsbool = input("Would you like to configure an NFS (y/n): ")
    if nfsbool == 'y':
        nfsjson = {"enabled": bool("true")}
        dataobj['nfs'] = nfsjson
    print()
    cifsbool = input("Would you like to configure an CIFS (y/n): ")
    if cifsbool == 'y':
        fqdn = input("Enter the name of FQDN: ")
        aduser = input("Enter the User: "******"Enter the password: "******"Enter the AD Name: ")
        cifsjson = {
            "ad_domain": {
                "fqdn": fqdn,
                "password": adpassword,
                "user": aduser
            },
            "enabled": bool("true"),
            "name": adname
        }
        dataobj['cifs'] = cifsjson
    print()
    dnsbool = input("Would you like to configure an DNS (y/n): ")
    if dnsbool == 'y':
        domain = input("Enter the name of Domain: ")
        server = input("Enter the Server: ")
        dnsjson = {"domains": [domain], "servers": [server]}
        dataobj['dns'] = dnsjson

    print(dataobj)
    url = "https://{}/api/svm/svms".format(cluster)
    try:
        response = requests.post(url,
                                 headers=headers_inc,
                                 json=dataobj,
                                 verify=False)
    except requests.exceptions.HTTPError as err:
        print(err)
        print(response)
        sys.exit(1)
    except requests.exceptions.RequestException as err:
        print(err)
        print(response)
        sys.exit(1)
    url_text = response.json()
    if 'error' in url_text:
        print(url_text)
        sys.exit(1)

    job_status = "https://{}{}".format(
        cluster, url_text['job']['_links']['self']['href'])
    try:
        job_response = requests.get(job_status,
                                    headers=headers_inc,
                                    verify=False)
    except requests.exceptions.HTTPError as err:
        print(err)
        print(job_response)
        sys.exit(1)
    except requests.exceptions.RequestException as err:
        print(err)
        print(job_response)
        sys.exit(1)
    url_text = job_response.json()
    if 'error' in url_text:
        print(url_text)
        sys.exit(1)
    job_status = job_response.json()
    check_job_status(job_status, headers_inc, cluster)
Ejemplo n.º 6
0
def create_svm() -> None:
    """Create SVM"""
    print()
    svmname = input("Enter the name of the SVM: ")
    dataobj = {}
    dataobj['name'] = svmname
    dataobj['language'] = "c.utf_8"
    ipspaceobj = {"name": "Default"}
    dataobj['ipspace'] = ipspaceobj
    intbool = input("Would you like to configure an Interface (y/n): ")
    if intbool == 'y':
        mgmtlif = input("Enter the name of Management LIF: ")
        ipadd = input("Enter the IP address: ")
        nmask = input("Enter the NetMask: ")
        bdomain = input("Enter the broadcast-domain: ")
        show_node()
        hnode = input("Enter the Home Node: ")
        uuids = input("Enter the UUID: ")
        intjson = [{
            "ip": {
                "address": ipadd,
                "netmask": nmask
            },
            "location": {
                "broadcast_domain": {
                    "name": bdomain
                },
                "home_node": {
                    "name": hnode,
                    "uuid": uuids
                }
            },
            "name": mgmtlif,
            "service_policy": "default-data-files"
        }]
        dataobj['ip_interfaces'] = intjson
    nfsbool = input("Would you like to configure an NFS (y/n): ")
    if nfsbool == 'y':
        nfsjson = {"enabled": bool("true")}
        dataobj['nfs'] = nfsjson
        print(dataobj)
    cifsbool = input("Would you like to configure an CIFS (y/n): ")
    if cifsbool == 'y':
        fqdn = input("Enter the name of FQDN: ")
        aduser = input("Enter the User: "******"Enter the password: "******"Enter the AD Name: ")
        cifsjson = {
            "ad_domain": {
                "fqdn": fqdn,
                "password": adpassword,
                "user": aduser
            },
            "enabled": bool("true"),
            "name": adname
        }
        dataobj['cifs'] = cifsjson
        print(dataobj)
    dnsbool = input("Would you like to configure an DNS (y/n): ")
    if dnsbool == 'y':
        domain = input("Enter the name of Domain: ")
        server = input("Enter the Server: ")
        dnsjson = {"domains": [domain], "servers": [server]}
        dataobj['dns'] = dnsjson
        print(dataobj)

    try:
        svm = Svm.from_dict(dataobj)
        if svm.post(poll=True):
            print("SVM  %s created Successfully" % svm.name)
    except NetAppRestError as error:
        print("Exception caught :" + str(error))