From f98a7bb1e1b209623a77710c7620389b6dbf0ee1 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Sun, 15 Nov 2009 12:51:14 +0000 Subject: [PATCH] example --- PLC/Accessors/Accessors_example_ple.py | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 PLC/Accessors/Accessors_example_ple.py diff --git a/PLC/Accessors/Accessors_example_ple.py b/PLC/Accessors/Accessors_example_ple.py new file mode 100644 index 0000000..94ef84e --- /dev/null +++ b/PLC/Accessors/Accessors_example_ple.py @@ -0,0 +1,51 @@ +# Thierry Parmentelat - INRIA +# $Id: Accessors_site.py 14587 2009-07-19 13:18:50Z thierry $ +# $URL: http://svn.planet-lab.org/svn/PLCAPI/tags/PLCAPI-4.3-29/PLC/Accessors/Accessors_site.py $ +# + +methods=[] + +from PLC.Nodes import Node +from PLC.Interfaces import Interface +from PLC.Slices import Slice +#from PLC.Ilinks import Ilink + +from PLC.Accessors.Factory import define_accessors, all_roles, tech_roles + +import sys +current_module = sys.modules[__name__] + +#### example 1 : attach vlan ids on interfaces +# The third argument expose_in_api is a boolean flag that tells whether this tag may be handled +# through the Add/Get/Update methods as a native field +# +#define_accessors(current_module, Interface, "Vlan", "vlan", +# "interface/general", "tag for setting VLAN id", +# get_roles=all_roles, set_roles=tech_roles) + +##### example 2 : +# the slice page uses the category field in the following way +# it considers all tag types for which 'category' matches 'node*/ui*' +# for these, the category field is split into pieces using / +# the parts may define the following settings: +# header: to use instead of the full tagname (in which case a footnote appears with the 'description') +# type: exported as the type for the javascript table (used for how-to-sort) +# rank: to be used for sorting columns (defaults to tagname) + +#################### MySlice tags +define_accessors(current_module, Node, "Reliability", "reliability", + # category + "node/monitor/ui/header=R/type=int/rank=ad", + # description : used to add a footnote to the table if header is set in category + "average reliability (% uptime) over the last week", + get_roles=all_roles, set_roles=tech_roles, expose_in_api=True) + +define_accessors(current_module, Node, "Load", "load", + "node/monitor/ui/header=l/type=sortAlphaNumericBottom", + "average load (% CPU utilization) over the last week", + get_roles=all_roles, set_roles=tech_roles, expose_in_api=True) + +define_accessors(current_module, Node, "ASNumber", "asnumber", + "node/location/ui/header=AS/type=sortAlphaNumericBottom/rank=z", + "Autonomous System id", + get_roles=all_roles, set_roles=tech_roles, expose_in_api=True) -- 2.43.0