- Change .py files to use 4-space indents and no hard tab characters.
[plcapi.git] / PLC / Accessors / Accessors_example_ple.py
1 # Thierry Parmentelat - INRIA
2 # $Id: Accessors_site.py 14587 2009-07-19 13:18:50Z thierry $
3 # $URL: http://svn.planet-lab.org/svn/PLCAPI/tags/PLCAPI-4.3-29/PLC/Accessors/Accessors_site.py $
4 #
5
6 methods=[]
7
8 from PLC.Nodes import Node
9 from PLC.Interfaces import Interface
10 from PLC.Slices import Slice
11 #from PLC.Ilinks import Ilink
12
13 from PLC.Accessors.Factory import define_accessors, all_roles, tech_roles
14
15 import sys
16 current_module = sys.modules[__name__]
17
18 #### example 1 : attach vlan ids on interfaces
19 # The third argument expose_in_api is a boolean flag that tells whether this tag may be handled
20 #   through the Add/Get/Update methods as a native field
21 #
22 #define_accessors(current_module, Interface, "Vlan", "vlan",
23 #                  "interface/general", "tag for setting VLAN id",
24 #                  get_roles=all_roles, set_roles=tech_roles)
25
26 ##### example 2 :
27 # the slice page uses the category field in the following way
28 # it considers all tag types for which 'category' matches 'node*/ui*'
29 # for these, the category field is split into pieces using /
30 # the parts may define the following settings:
31 # header: to use instead of the full tagname (in which case a footnote appears with the 'description')
32 # type: exported as the type for the javascript table (used for how-to-sort)
33 # rank: to be used for sorting columns (defaults to tagname)
34
35 #################### MySlice tags
36 define_accessors(current_module, Node, "Reliability", "reliability",
37                  # category
38                  "node/monitor/ui/header=R/type=int/rank=ad",
39                  # description : used to add a footnote to the table if header is set in category
40                  "average reliability (% uptime) over the last week",
41                   get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)
42
43 define_accessors(current_module, Node, "Load", "load",
44                  "node/monitor/ui/header=l/type=sortAlphaNumericBottom",
45                  "average load (% CPU utilization) over the last week",
46                   get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)
47
48 define_accessors(current_module, Node, "ASNumber", "asnumber",
49                  "node/location/ui/header=AS/type=sortAlphaNumericBottom/rank=z",
50                  "Autonomous System id",
51                  get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)