define_accessors accepts a list of classes if needed
[plcapi.git] / PLC / Accessors / Accessors_standard.py
1 #
2 # Thierry Parmentelat - INRIA
3 #
4 from PLC.Nodes import Node
5 from PLC.Interfaces import Interface
6 from PLC.Slices import Slice
7 from PLC.Slices import Slice
8 from PLC.Sites import Site
9 from PLC.Persons import Person
10 #from PLC.Ilinks import Ilink
11
12 from PLC.Accessors.Factory import define_accessors, admin_roles, all_roles, tech_roles
13
14 import sys
15 current_module = sys.modules[__name__]
16
17 # NOTE.
18 # The 'Get' and 'Set' accessors defined here automagically create the corresponding TagType in the database
19 # for safety, some crucial tags are forced to be created at plc startup time, through the db-config.d mechanism
20 #
21
22 # These following accessors are mostly of interest for implementing the
23 # GetSliceFamily method, that takes into account the vref attribute,
24 # as well as the 3 attributes below, and the PLC_FLAVOUR config category
25
26 ### slice vref
27 define_accessors(current_module, Slice, "Vref", "vref",
28                  "slice/config", "vserver reference image name",
29                  set_roles=["admin","pi","user"], expose_in_api=True)
30 define_accessors(current_module, Slice, "Initscript","initscript",
31                  "slice/usertools", "Slice initialization script",
32                  set_roles=["admin","pi","user"], expose_in_api=True)
33
34 # xxx the accessor factory should enforce the category, descriptions and roles provided here.
35 # BootManager might need to set any of these 3, so 'node' needs to be in set_roles
36 # to tweaks the installed version on nodes and slivers
37 define_accessors(current_module, [Slice,Node], "Arch", "arch",
38                  "node/slice/config", "node arch or slivers arch",
39                  set_roles=["pi","user","tech","node"], expose_in_api=True)
40 define_accessors(current_module, [Slice,Node], "Pldistro", "pldistro",
41                  "node/slice/config", "PlanetLab distribution to use for node or slivers",
42                  set_roles=["pi","user","tech","node"], expose_in_api=True)
43 define_accessors(current_module, [Slice,Node], "Fcdistro", "fcdistro",
44                  "node/slice/config", "Fedora or CentOS distribution to use for node or slivers",
45                  set_roles=["pi","user","tech","node"], expose_in_api=True)
46
47 # node deployment (alpha, beta, ...)
48 define_accessors(current_module, Node, "Deployment", "deployment",
49                  "node/operation", 'typically "alpha", "beta", or "production"',
50                  set_roles=["admin"], expose_in_api=True)
51 # extensions - leave this to admin only until the semantics is made more clear
52 define_accessors(current_module, Node, "Extensions", "extensions",
53                  "node/config", "space-separated list of extensions to install",
54                  set_roles=["admin"],expose_in_api=True)
55 # access HRN - this is the ideal definition of roles, even if AddNodeTag cannot handle this
56 define_accessors(current_module, Node, "Hrn","hrn",
57                  "node/sfa", "SFA human readable name",
58                  set_roles=all_roles, expose_in_api=True)
59
60 # test nodes perform their installation from an uncompressed bootstrapfs
61 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs",
62                  "node/config", "use uncompressed bootstrapfs when set",
63                  set_roles=tech_roles)
64
65 # the tags considered when creating a boot CD
66 define_accessors(current_module, Node, "Serial", "serial",
67                  "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium",
68                  set_roles=tech_roles)
69 define_accessors(current_module, Node, "Cramfs", "cramfs",
70                  "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium",
71                  set_roles=tech_roles)
72 define_accessors(current_module, Node, "Kvariant", "kvariant",
73                  "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium",
74                  set_roles=tech_roles)
75 define_accessors(current_module, Node, "Kargs", "kargs",
76                  "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium",
77                  set_roles=tech_roles)
78 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
79                  "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium",
80                  set_roles=tech_roles)
81
82 # interface
83 # xxx - don't expose yet in api interface and slices dont know how to use that yet
84 define_accessors(current_module, Interface, "Ifname", "ifname",
85                  "interface/config", "linux name",
86                  set_roles=tech_roles, expose_in_api=True)
87 define_accessors(current_module, Interface, "Driver", "driver",
88                  "interface/config", "driver name",
89                  set_roles=tech_roles)
90 define_accessors(current_module, Interface, "Alias", "alias",
91                  "interface/config", "interface alias",
92                  set_roles=tech_roles)
93 define_accessors(current_module, Interface, "Backdoor", "backdoor",
94                  "interface/hidden", "For testing new settings",
95                  set_roles=admin_roles)