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