Beispiel #1
0
def patch_svm() -> None:
    """Update SVM"""
    print()
    show_svm()
    print("=============================================")
    svmname = input("Enter the name of the SVM that needs to be updated: ")
    svm = Svm.find(name=svmname)
    lanbool = input("Would you like to update language (y/n): ")
    if lanbool == 'y':
        lan = input(
            "Enter the name of language the you would like to update: ")
        svm.language = lan
    namebool = input("Would you like to update the name (y/n): ")
    if namebool == 'y':
        nam = input("Enter the name of SVM: ")
        svm.name = nam
    snapbool = input("Would you like to update an SnapShot Policy (y/n): ")
    if snapbool == 'y':
        snap = input(
            "Enter the name of default snapshot policy that needs to ne updated : "
        )
        svm.snapshot_policy = snap
    aggrbool = input(
        "Would you like to update the SVM with new Aggregate (y/n): ")
    if aggrbool == 'y':
        aggr = input(
            "Enter the name of aggregates(with commas) that needs to be updated : "
        )
        svm.aggregates.name = aggr

    try:
        if svm.patch(poll=True):
            print("SVM  %s has been updated/patched Successfully" % svm.name)
    except NetAppRestError as error:
        print("Exception caught :" + str(error))
Beispiel #2
0
def create_cifs_server(vserver_name: str, domain_name: str, cifs_server: str,
                       server_ip: str) -> None:
    """Creates a CIFS server"""

    SVM = Svm.find(name=vserver_name)

    data = {
        'name': cifs_server,
        'scope': 'svm',
        'svm': {
            'name': vserver_name,
            'uuid': SVM.uuid
        },
        'ad_domain': {
            'fqdn': domain_name,
            'organizational_unit': 'CN=Computers',
            'user': '******',
            'password': '******'
        },
        'netbios': {
            'wins_servers': [server_ip]
        },
        'enabled': 'True'
    }

    cifs_service = CifsService(**data)

    try:
        cifs_service.post()
        print("CIFS Server %s created successfully" % cifs_service.name)
    except NetAppRestError as err:
        print("Error: CIFS Server was not created: %s" % err)
    return
Beispiel #3
0
def create_export_policy(vserver_name: str, ex_path: str,
                         host_name: str) -> None:
    """Creates an export policy for an SVM"""

    SVM = Svm.find(name=vserver_name)

    data = {
        'name':
        ex_path,
        'svm': {
            'name': vserver_name,
            'uuid': SVM.uuid
        },
        'rules': [
            {
                'clients': [{
                    'match': '0.0.0.0/0'
                }],
                'ro_rule': ['any'],
                'rw_rule': ['any'],
                'anonymous_user': '******',
            },
        ]
    }

    export_policy = ExportPolicy(**data)

    try:
        export_policy.post()
        print("Export Policy for NFS Server %s created successfully" %
              export_policy.name)
    except NetAppRestError as err:
        print("Error: Export Policy was not created: %s" % err)
    return
Beispiel #4
0
def create_nfs_server(vserver_name: str, domain_name: str, nfs_server: str,
                      server_ip: str) -> None:
    """Creates a NFS server"""

    SVM = Svm.find(name=vserver_name)

    data = {
        'name': nfs_server,
        'scope': 'svm',
        'svm': {
            'name': vserver_name,
            'uuid': SVM.uuid
        },
        'protocol': {
            'v4_id_domain': domain_name
        },
        #'protocol': {'v3_enabled': bool('true')},
        'vstorage_enabled': 'true'
    }

    nfs_service = NfsService(**data)

    try:
        nfs_service.post()
        print("NFS Server %s created successfully" % nfs_server)
    except NetAppRestError as err:
        print("Error: NFS Server was not created: %s" % err)
    return
Beispiel #5
0
def stop_svm() -> None:
    """Stop SVM"""
    print()
    show_svm()
    print("=============================================")
    print()
    svmname = input(
        "Enter the name of the SVM name that needs to be stopped: ")
    svm = Svm.find(name=svmname)
    svm.state = "stopped"

    try:
        if svm.patch(poll=True):
            print("SVM  %s has been stopped Successfully." % svm.name)
    except NetAppRestError as error:
        print("Exception caught :" + str(error))
Beispiel #6
0
def delete_svm() -> None:
    """Delete SVM"""
    print()
    show_svm()
    print("=============================================")
    print()
    svmname = input("Enter the name of the SVM that needs to be deleted: ")
    try:
        svm = Svm.find(name=svmname)
    except NetAppRestError as error:
        print("Exception caught :" + str(error))

    try:
        if svm.delete(poll=True):
            print("SVM  %s has been deleted Successfully." % svm.name)
    except NetAppRestError as error:
        print("Exception caught :" + str(error))
def start_svm() -> None:
    """Start SVM"""
    print()
    show_svm()
    print()
    print("=============================================")
    svmname = input(
        "Enter the name of the SVM name that needs to be started: ")
    svm = Svm.find(name=svmname)
    svm.state = "running"

    try:
        if svm.patch(poll=True):
            print("SVM  %s has been started Successfully" % svm.name)
    except NetAppRestError as error:
        print("Error:- " % error.http_err_response.http_response.text)
        print("Exception caught :" + str(error))
from netapp_ontap import config
from netapp_ontap import HostConnection
from netapp_ontap.resources import Cluster, Aggregate, Port, Volume, Autosupport, IpInterface, Disk, Chassis, Account, Svm

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

conn = HostConnection('192.168.1.200',
                      username='******',
                      password='******',
                      verify=False)

config.CONNECTION = conn
clus = Cluster()
clus.get()
print(clus)

aggr = Aggregate.find()
aggr.get()
print(aggr.name, aggr.node)

svm = Svm.find(name="study")
svm.get()
print(svm.to_dict())
Beispiel #9
0
except NetAppRestError as err:
	print("--> Error: Volume was not deleted:\n{}".format(err))
print("")

# CIFS Server
print("--> Starting CIFS server delete operation")
try:
	cifs = CifsService.find(name=global_vars["PRI_SVM"])
	if cifs:
		cifs.delete(body={
			"ad_domain": {
				"fqdn": global_vars["PRI_AD_DOMAIN"],
				"user": global_vars["PRI_AD_USER"], 
				"password": global_vars["PRI_AD_PASS"]
			}
		})
		print("--> CIFS server {} deleted successfully".format(cifs.name))
except NetAppRestError as err:
	print("--> Error: CIFS server was not deleted:\n{}".format(err))
print("")

# SVM
print("--> Starting SVM delete operation")
try:
	svm = Svm.find(**{"name": global_vars["PRI_SVM"]})
	if svm:
		svm.delete()
		print("--> SVM {} deleted successfully".format(svm.name))
except NetAppRestError as err:
	print("--> Error: SVM was not deleted:\n{}".format(err))
print("")