create the disabled_registration site tag that allows to remove a specific site from...
[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 # The GetSliceFamily and GetNodeFlavour methods take into account various tags, 
22 # esp. arch, fcdistro, pldistro, vref (for slices) and deployment (for nodes)
23 # as well as the global PLC_FLAVOUR config category
24 # in order to return all configuration details for a given node or slice
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","node"], expose_in_api=True)
30 # this contains the actual script text
31 # if set, it supersedes 'initscript'
32 define_accessors(current_module, Slice, "InitscriptCode","initscript_code",
33                  "slice/usertools", "Slice initialization script code",
34                  set_roles=["admin","pi","user"], expose_in_api=True)
35 # this may contain a *name* that refers to the GetInitScripts
36 # it was initially designed to share scripts among slices
37 define_accessors(current_module, Slice, "Initscript","initscript",
38                  "slice/usertools", "Slice initialization script name",
39                  set_roles=["admin","pi","user"], expose_in_api=True)
40
41 # BootManager might need to set any of these 3, so 'node' needs to be in set_roles
42 # needs 'pi' and 'tech' for managing their node
43 # needs 'user' for managing their slices
44 # needs 'admin' so the Set method is accessible
45 define_accessors(current_module, [Slice,Node], "Arch", "arch",
46                  "node/slice/config", "node arch or slivers arch",
47                  set_roles=all_roles, expose_in_api=True)
48 define_accessors(current_module, [Slice,Node], "Pldistro", "pldistro",
49                  "node/slice/config/sfa", "PlanetLab distribution to use for node or slivers",
50                  set_roles=all_roles, expose_in_api=True)
51 # fc of course historically was for fedora core
52 define_accessors(current_module, [Slice,Node], "Fcdistro", "fcdistro",
53                  "node/slice/config", "Linux distribution to use for node or slivers",
54                  set_roles=all_roles, expose_in_api=True)
55
56 # the virtualization model to use - this is only used by the bootmanager for 
57 # picking the right options e.g. prior to reinstalling
58 # see PLC_FLAVOUR_VIRT_MAP to see how the default gets computed
59 define_accessors(current_module, Node, "Virt", "virt",
60                  "node/operation", 'typically "vs" or "lxc"',
61                  set_roles=all_roles, expose_in_api=True)
62 # node deployment (alpha, beta, ...)
63 define_accessors(current_module, Node, "Deployment", "deployment",
64                  "node/operation", 'typically "alpha", "beta", or "production"',
65                  set_roles=["admin"], expose_in_api=True)
66 # extensions - leave this to admin only until the semantics is made more clear
67 define_accessors(current_module, Node, "Extensions", "extensions",
68                  "node/config", "space-separated list of extensions to install",
69                  set_roles=["admin"],expose_in_api=True)
70 # access HRN - this is the ideal definition of roles, even if AddNodeTag cannot handle this
71 define_accessors(current_module, [Node,Person,Slice,Site] , "Hrn", "hrn",
72                  "node/person/slice/site/sfa", "SFA human readable name",
73                  set_roles=all_roles, expose_in_api=True)
74
75 # test nodes perform their installation from an uncompressed bootstrapfs
76 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs",
77                  "node/config", "use uncompressed bootstrapfs when set",
78                  set_roles=tech_roles)
79
80 # the tags considered when creating a boot CD
81 define_accessors(current_module, Node, "Serial", "serial",
82                  "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium",
83                  set_roles=tech_roles)
84 define_accessors(current_module, Node, "Cramfs", "cramfs",
85                  "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium",
86                  set_roles=tech_roles)
87 define_accessors(current_module, Node, "Kvariant", "kvariant",
88                  "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium",
89                  set_roles=tech_roles)
90 define_accessors(current_module, Node, "Kargs", "kargs",
91                  "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium",
92                  set_roles=tech_roles)
93 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
94                  "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium",
95                  set_roles=tech_roles)
96
97 # interface
98 # xxx - don't expose yet in api interface and slices dont know how to use that yet
99 define_accessors(current_module, Interface, "Ifname", "ifname",
100                  "interface/config", "linux name",
101                  set_roles=tech_roles, expose_in_api=True)
102 define_accessors(current_module, Interface, "Driver", "driver",
103                  "interface/config", "driver name",
104                  set_roles=tech_roles)
105 define_accessors(current_module, Interface, "Alias", "alias",
106                  "interface/config", "interface alias",
107                  set_roles=tech_roles)
108 define_accessors(current_module, Interface, "Backdoor", "backdoor",
109                  "interface/hidden", "For testing new settings",
110                  set_roles=admin_roles)
111
112 # we need to identify objects created through SFA interfaces
113 define_accessors(current_module, [Person,Slice,Site] , "SfaCreated", "sfa_created",
114                  "person/slice/site/sfa", "Tag objects created through SFA interfaces",
115                  set_roles=all_roles, expose_in_api=True)
116
117 # set any value to this tag to prevent a site from showing up
118 # in the person registration form
119 define_accessors(current_module, Site, "DisabledRegistration", "disabled_registration",
120                  "site", "Sites that have a non-void value are excluded from the drop-down list on the registration form",
121                  set_roles=admin_roles, expose_in_api=True)