def create_data_interface(vserver_name: str, ip_address: str, ip_netmask) -> None: """Creates an SVM-scoped IP Interface""" data = { 'name': 'Data1', 'ip': { 'address': ip_address, 'netmask': ip_netmask }, 'enabled': True, 'scope': 'svm', 'svm': { 'name': vserver_name }, #'home_port': { # 'name': 'e0d', # 'node': 'cluster1-01' #} 'location': { 'auto_revert': True, 'broadcast_domain': { 'name': 'Default' }, } } ip_interface = IpInterface(**data) try: ip_interface.post() print("Ip Interface %s created successfully" % ip_interface.ip.address) except NetAppRestError as err: print("Error: IP Interface was not created: %s" % err) return
def list_interface(): """ List Interface""" print("\n List of Interface:- \n") try: for interface in IpInterface.get_collection(): print("Interface Name:- %s; Inteface UUID:- %s " % (interface.name, interface.uuid)) except NetAppRestError as error: print("Exception caught :" + str(error))
def show_interface() -> None: """ List Interface""" print("\n List of Interface:- \n") try: for interface in IpInterface.get_collection(): print("Interface Name:- %s; Inteface UUID:- %s " % (interface.name, interface.uuid)) except NetAppRestError as error: print("Error:- " % error.http_err_response.http_response.text) print("Exception caught :" + str(error))
async def get_interfaces(self, message): """ A skills function to get all interfaces on the cluster. The parser looks for the message argument. Arguments: message {str} -- get interfaces state on cluster """ interfaces = [] for interface in IpInterface.get_collection(): interface.get() interfaces.append([interface.name, interface.state]) await message.respond('All done! Response: {}'.format(interfaces))
def delete_interface() -> None: """ delete Interface""" print("----------Patch Interface-----------") print() show_interface() int_name = input("Enter the name of the Interface Name :- ") try: ipint = IpInterface.find(name=int_name) if ipint.delete(poll=True): print("Interface deleted successfully.") except NetAppRestError as error: print("Exception caught :" + str(error))
def create_mgmt_interface(vserver_name: str, interface_name: str, node_name: str, ip_address: str, ip_netmask: str) -> None: """Creates an SVM-scoped IP Interface""" data = { 'name': interface_name, 'ip': { 'address': ip_address, 'netmask': ip_netmask }, 'enabled': True, 'scope': 'svm', 'svm': { 'name': vserver_name }, 'port': { 'name': 'e0c', 'node': node_name }, 'location': { 'auto_revert': True, 'broadcast_domain': { 'name': 'Default' }, } } ip_interface = IpInterface(**data) try: ip_interface.post() print("Management Ip Interface %s created successfully" % ip_interface.ip.address) except NetAppRestError as err: print("Error: Management IP Interface was not created: %s" % err) return
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 patch_interface() -> None: """ Patch Interface""" print("----------Patch Interface-----------") print() show_interface() int_name = input("Enter the name of the Interface Name :- ") int_new_name = input( "Enter the new name of the interface to be updated :- ") try: ipint = IpInterface.find(name=int_name) ipint.name = int_new_name if ipint.patch(poll=True): print("Interface updated successfully.") except NetAppRestError as error: print("Exception caught :" + str(error))
### Step 3 - Get & print details # SVMs print("--> Printing SVM details") print("{:<20}{:<15}{:<10}{:<30}".format("Name", "IP Space", "State", "Comment")) for svm in Svm.get_collection(): svm.get() print("{:<20}{:<15}{:<10}{:<30}".format(svm.name, svm.ipspace.name, svm.state, svm.comment)) print("") # Interfaces print("--> Printing network interface details") print("{:<20}{:<25}{:<20}{:<15}".format("SVM", "Name", "IP", "Current Port")) for lif in IpInterface.get_collection(**{"scope": "svm"}): lif.get() print("{:<20}{:<25}{:<20}{:15}".format( lif.svm.name, lif.name, lif.ip.address + "/" + lif.ip.netmask, lif.location.node.name + ":" + lif.location.port.name)) 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("")
username=global_vars["PRI_CLU_USER"], password=global_vars["PRI_CLU_PASS"], verify=False) ### Step 3 - Create operation lif = IpInterface.from_dict({ "name": global_vars["PRI_SVM"] + "_cifs_01", "svm": { "name": global_vars["PRI_SVM"] }, "ip": { "address": global_vars["PRI_SVM_CIFS_IP"], "netmask": global_vars["PRI_SVM_CIFS_NETMASK"] }, "location": { "home_port": { "name": global_vars["PRI_DATA_PORT"], "node": { "name": global_vars["PRI_NODE"] } } }, "service_policy": { "name": "default-data-files" } }) print("--> Starting interface create operation") try: lif.post() print("--> CIFS interface \"{}\" created successfully".format(lif.name))
username=global_vars["PRI_CLU_USER"], password=global_vars["PRI_CLU_PASS"], verify=False) ### Step 3 - Create operation lif = IpInterface.from_dict({ "name": global_vars["PRI_SVM"], "svm": { "name": global_vars["PRI_SVM"] }, "ip": { "address": global_vars["PRI_SVM_IP"], "netmask": global_vars["PRI_SVM_NETMASK"] }, "location": { "home_port": { "name": global_vars["PRI_MGMT_PORT"], "node": { "name": global_vars["PRI_NODE"] } } }, "service_policy": { "name": "default-management" } }) print("--> Starting management interface create operation") try: lif.post() print("--> Interface \"{}\" created successfully".format(lif.name))