Module system
[hide private]
[frames] | no frames]

Source Code for Module system

 1  # -*- encoding: utf8 -*-
 
 2  """
 
 3      System module:  aXAPI system management implementation.
 
 4      
 
 5      Author : Richard Zhang, A10 Networks (c)
 
 6      email  : rzhang@a10networks.com
 
 7      Date   : 03/07/2012
 
 8  """ 
 9  
 
10  import method_call 
11  from  base import AxObject, AxAPIError 
12 13 -class SystemNtp(AxObject):
14 """ 15 Implementation of the aXAPI system.ntp.* method to 16 set up the NTP 17 18 Usage: 19 # create the NTP server at 2.2.2.2 at disabled status 20 ntp1 = SystemNtp(server="2.2.2.2", status=STATUS_DISABLED) 21 ntp1.add() 22 # enable the NTP server: 23 ntp1.status = STATUS_ENABLED. 24 ntp1.update() 25 26 # get all NTP configuration 27 ntp_list = SystemNtp.getAll() 28 for aNtp in ntp_list: 29 # use aNtp here 30 ... 31 """ 32 33 __display__ = ["server", "status"] 34 __obj_name__ = 'ntp' 35 __xml_convrt__ = {"ntp_list": "ntp"} 36 37 @staticmethod
38 - def getAll():
39 """ method : system.ntp.get 40 Returns a list of NTP configuration in SystemNtp instance. 41 """ 42 try: 43 res = method_call.call_api(SystemNtp(), method = "system.ntp.get", format = "url") 44 smtp_list = [] 45 for item in res["smtp_template_list"]: 46 smtp_list.append( SystemNtp(**item) ) 47 return smtp_list 48 except AxAPIError: 49 return None
50
51 - def add(self):
52 """ method: system.ntp.add 53 Create the NTP entry. 54 """ 55 try: 56 alist = list() 57 alist.append(self.getObjectDict()) 58 ntp = SystemNtp(ntp_list = alist) 59 method_call.call_api(self, method = "system.ntp.add", format = "url", post_data = ntp.getRequestPostDataXml()) 60 return 0 61 except AxAPIError, e: 62 return e.code
63
64 - def delete(self):
65 """ method: system.ntp.delete 66 Delete the NTP entry. 67 """ 68 try: 69 alist = list() 70 alist.append(self.getObjectDict()) 71 ntp = SystemNtp(ntp_list = alist) 72 method_call.call_api(self, method = "system.ntp.delete", format = "url", post_data = ntp.getRequestPostDataXml()) 73 return 0 74 except AxAPIError, e: 75 return e.code
76
77 - def update(self):
78 """ method: system.ntp.update 79 Update the NTP entry. 80 """ 81 try: 82 alist = list() 83 alist.append(self.getObjectDict()) 84 ntp = SystemNtp(ntp_list = alist) 85 method_call.call_api(self, method = "system.ntp.update", format = "url", post_data = ntp.getRequestPostDataXml()) 86 return 0 87 except AxAPIError, e: 88 return e.code
89