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 # 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
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)
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)
56 # node deployment (alpha, beta, ...)
57 define_accessors(current_module, Node, "Deployment", "deployment",
58 "node/operation", 'typically "alpha", "beta", or "production"',
59 set_roles=["admin"], expose_in_api=True)
60 # extensions - leave this to admin only until the semantics is made more clear
61 define_accessors(current_module, Node, "Extensions", "extensions",
62 "node/config", "space-separated list of extensions to install",
63 set_roles=["admin"],expose_in_api=True)
64 # access HRN - this is the ideal definition of roles, even if AddNodeTag cannot handle this
65 define_accessors(current_module, Node, "Hrn","hrn",
66 "node/person/sfa", "SFA human readable name",
67 set_roles=all_roles, expose_in_api=True)
69 define_accessors(current_module, Person, "Hrn","hrn",
70 "node/person/sfa", "SFA human readable name",
71 set_roles=all_roles, expose_in_api=True)
73 # test nodes perform their installation from an uncompressed bootstrapfs
74 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs",
75 "node/config", "use uncompressed bootstrapfs when set",
78 # the tags considered when creating a boot CD
79 define_accessors(current_module, Node, "Serial", "serial",
80 "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium",
82 define_accessors(current_module, Node, "Cramfs", "cramfs",
83 "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium",
85 define_accessors(current_module, Node, "Kvariant", "kvariant",
86 "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium",
88 define_accessors(current_module, Node, "Kargs", "kargs",
89 "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium",
91 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
92 "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium",
96 # xxx - don't expose yet in api interface and slices dont know how to use that yet
97 define_accessors(current_module, Interface, "Ifname", "ifname",
98 "interface/config", "linux name",
99 set_roles=tech_roles, expose_in_api=True)
100 define_accessors(current_module, Interface, "Driver", "driver",
101 "interface/config", "driver name",
102 set_roles=tech_roles)
103 define_accessors(current_module, Interface, "Alias", "alias",
104 "interface/config", "interface alias",
105 set_roles=tech_roles)
106 define_accessors(current_module, Interface, "Backdoor", "backdoor",
107 "interface/hidden", "For testing new settings",
108 set_roles=admin_roles)