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
print("") # DNS print("--> Printing DNS details") print("{:<20}{:<20}{:<20}".format("SVM", "Domains", "Servers")) for dns in Dns.get_collection(): dns.get() print("{:<20}{:<20}{:<20}".format(dns.svm.name, str(dns.domains), str(dns.servers))) print("") # CIFS print("--> Printing CIFS details") print("{:<20}{:<20}{:<20}{:<20}".format("SVM", "Server Name", "Domain", "Comment")) for cifs in CifsService.get_collection(): cifs.get() print("{:<20}{:<20}{:<20}{:<20}".format(cifs.svm.name, cifs.name, cifs.ad_domain.fqdn, cifs.comment)) print("") # NFS print("--> Printing NFS details") print("{:<20}{:<10}{:<10}{:<10}{:<10}".format("SVM", "State", "v3", "v4.0", "v4.1")) for nfs in NfsService.get_collection(): nfs.get() print("{:<20}{:<10}{:<10}{:<10}{:<10}".format( nfs.svm.name, nfs.state, str(nfs.protocol.v3_enabled), str(nfs.protocol.v40_enabled), str(nfs.protocol.v41_enabled))) print("")
### Step 3 - Delete operation # Volume print("--> Starting volume delete operation") try: for volume in Volume.get_collection( **{"svm.name":global_vars["PRI_SVM"], "name":"!*_root"}): volume.delete() print("--> Volume {} deleted successfully".format(volume.name)) 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")
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 cifs = CifsService.from_dict({ "name": global_vars["PRI_SVM"], "svm": { "name": global_vars["PRI_SVM"] }, "ad_domain": { "fqdn": global_vars["PRI_AD_DOMAIN"], "user": global_vars["PRI_AD_USER"], "password": global_vars["PRI_AD_PASS"] }, "comment": "Created with ONTAP PCL" }) print("--> Starting CIFS create operation") try: cifs.post() print("--> CIFS Server \"{}\" created successfully".format(cifs.name)) except NetAppRestError as err: print("--> Error: SVM was not created:\n{}".format(err)) print("")