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 define_accessors(current_module, Slice, "Initscript","initscript",
29 "slice/usertools", "Slice initialization script",
30 set_roles=["admin","pi","user"], expose_in_api=True)
32 # BootManager might need to set any of these 3, so 'node' needs to be in set_roles
33 # needs 'pi' and 'tech' for managing their node
34 # needs 'user' for managing their slices
35 # needs 'admin' so the Set method is accessible
36 define_accessors(current_module, [Slice,Node], "Arch", "arch",
37 "node/slice/config", "node arch or slivers arch",
38 set_roles=["admin","pi","user","tech","node"], expose_in_api=True)
39 define_accessors(current_module, [Slice,Node], "Pldistro", "pldistro",
40 "node/slice/config", "PlanetLab distribution to use for node or slivers",
41 set_roles=["admin","pi","user","tech","node"], expose_in_api=True)
42 define_accessors(current_module, [Slice,Node], "Fcdistro", "fcdistro",
43 "node/slice/config", "Fedora or CentOS distribution to use for node or slivers",
44 set_roles=["admin","pi","user","tech","node"], expose_in_api=True)
46 # node deployment (alpha, beta, ...)
47 define_accessors(current_module, Node, "Deployment", "deployment",
48 "node/operation", 'typically "alpha", "beta", or "production"',
49 set_roles=["admin"], expose_in_api=True)
50 # extensions - leave this to admin only until the semantics is made more clear
51 define_accessors(current_module, Node, "Extensions", "extensions",
52 "node/config", "space-separated list of extensions to install",
53 set_roles=["admin"],expose_in_api=True)
54 # access HRN - this is the ideal definition of roles, even if AddNodeTag cannot handle this
55 define_accessors(current_module, Node, "Hrn","hrn",
56 "node/sfa", "SFA human readable name",
57 set_roles=all_roles, expose_in_api=True)
59 # test nodes perform their installation from an uncompressed bootstrapfs
60 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs",
61 "node/config", "use uncompressed bootstrapfs when set",
64 # the tags considered when creating a boot CD
65 define_accessors(current_module, Node, "Serial", "serial",
66 "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium",
68 define_accessors(current_module, Node, "Cramfs", "cramfs",
69 "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium",
71 define_accessors(current_module, Node, "Kvariant", "kvariant",
72 "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium",
74 define_accessors(current_module, Node, "Kargs", "kargs",
75 "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium",
77 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
78 "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium",
82 # xxx - don't expose yet in api interface and slices dont know how to use that yet
83 define_accessors(current_module, Interface, "Ifname", "ifname",
84 "interface/config", "linux name",
85 set_roles=tech_roles, expose_in_api=True)
86 define_accessors(current_module, Interface, "Driver", "driver",
87 "interface/config", "driver name",
89 define_accessors(current_module, Interface, "Alias", "alias",
90 "interface/config", "interface alias",
92 define_accessors(current_module, Interface, "Backdoor", "backdoor",
93 "interface/hidden", "For testing new settings",
94 set_roles=admin_roles)