2 # Thierry Parmentelat - INRIA
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
10 from PLC.Accessors.Factory import define_accessors, admin_roles, all_roles, tech_roles
13 current_module = sys.modules[__name__]
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
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
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, "InitscriptCode","initscript_code",
31 "slice/usertools", "Slice initialization script code",
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)
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/sfa", "PlanetLab distribution to use for node or slivers",
48 set_roles=["admin","pi","user","tech","node"], expose_in_api=True)
49 # fc of course historically was for fedora core
50 define_accessors(current_module, [Slice,Node], "Fcdistro", "fcdistro",
51 "node/slice/config", "Linux distribution to use for node or slivers",
52 set_roles=["admin","pi","user","tech","node"], expose_in_api=True)
54 # node deployment (alpha, beta, ...)
55 define_accessors(current_module, Node, "Deployment", "deployment",
56 "node/operation", 'typically "alpha", "beta", or "production"',
57 set_roles=["admin"], expose_in_api=True)
58 # extensions - leave this to admin only until the semantics is made more clear
59 define_accessors(current_module, Node, "Extensions", "extensions",
60 "node/config", "space-separated list of extensions to install",
61 set_roles=["admin"],expose_in_api=True)
62 # access HRN - this is the ideal definition of roles, even if AddNodeTag cannot handle this
63 define_accessors(current_module, Node, "Hrn","hrn",
64 "node/person/sfa", "SFA human readable name",
65 set_roles=all_roles, expose_in_api=True)
67 define_accessors(current_module, Person, "Hrn","hrn",
68 "node/person/sfa", "SFA human readable name",
69 set_roles=all_roles, expose_in_api=True)
71 # test nodes perform their installation from an uncompressed bootstrapfs
72 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs",
73 "node/config", "use uncompressed bootstrapfs when set",
76 # the tags considered when creating a boot CD
77 define_accessors(current_module, Node, "Serial", "serial",
78 "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium",
80 define_accessors(current_module, Node, "Cramfs", "cramfs",
81 "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium",
83 define_accessors(current_module, Node, "Kvariant", "kvariant",
84 "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium",
86 define_accessors(current_module, Node, "Kargs", "kargs",
87 "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium",
89 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
90 "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium",
94 # xxx - don't expose yet in api interface and slices dont know how to use that yet
95 define_accessors(current_module, Interface, "Ifname", "ifname",
96 "interface/config", "linux name",
97 set_roles=tech_roles, expose_in_api=True)
98 define_accessors(current_module, Interface, "Driver", "driver",
99 "interface/config", "driver name",
100 set_roles=tech_roles)
101 define_accessors(current_module, Interface, "Alias", "alias",
102 "interface/config", "interface alias",
103 set_roles=tech_roles)
104 define_accessors(current_module, Interface, "Backdoor", "backdoor",
105 "interface/hidden", "For testing new settings",
106 set_roles=admin_roles)