GetNodeFlavour exposes 'virt' based on node's 'virt' tag, or on PLC_FLAVOUR_VIRT_MAP
[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=["admin","pi","user","tech","node"], 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=["admin","pi","user","tech","node"], 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=["admin","pi","user","tech","node"], 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=["admin"], 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, "Hrn","hrn",
72                  "node/person/sfa", "SFA human readable name",
73                  set_roles=all_roles, expose_in_api=True)
74 # same for persons
75 define_accessors(current_module, Person, "Hrn","hrn",
76                  "node/person/sfa", "SFA human readable name",
77                  set_roles=all_roles, expose_in_api=True)
78
79 # test nodes perform their installation from an uncompressed bootstrapfs
80 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs",
81                  "node/config", "use uncompressed bootstrapfs when set",
82                  set_roles=tech_roles)
83
84 # the tags considered when creating a boot CD
85 define_accessors(current_module, Node, "Serial", "serial",
86                  "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium",
87                  set_roles=tech_roles)
88 define_accessors(current_module, Node, "Cramfs", "cramfs",
89                  "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium",
90                  set_roles=tech_roles)
91 define_accessors(current_module, Node, "Kvariant", "kvariant",
92                  "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium",
93                  set_roles=tech_roles)
94 define_accessors(current_module, Node, "Kargs", "kargs",
95                  "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium",
96                  set_roles=tech_roles)
97 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
98                  "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium",
99                  set_roles=tech_roles)
100
101 # interface
102 # xxx - don't expose yet in api interface and slices dont know how to use that yet
103 define_accessors(current_module, Interface, "Ifname", "ifname",
104                  "interface/config", "linux name",
105                  set_roles=tech_roles, expose_in_api=True)
106 define_accessors(current_module, Interface, "Driver", "driver",
107                  "interface/config", "driver name",
108                  set_roles=tech_roles)
109 define_accessors(current_module, Interface, "Alias", "alias",
110                  "interface/config", "interface alias",
111                  set_roles=tech_roles)
112 define_accessors(current_module, Interface, "Backdoor", "backdoor",
113                  "interface/hidden", "For testing new settings",
114                  set_roles=admin_roles)