fix adding nodes, and the sync target in the process
[plcapi.git] / PLC / Accessors / Accessors_standard.py
1 # Thierry Parmentelat - INRIA
2 # $Id$
3 # $URL$
4
5 from PLC.Nodes import Node
6 from PLC.Interfaces import Interface
7 from PLC.Slices import Slice
8 from PLC.Slices import Slice
9 from PLC.Sites import Site
10 from PLC.Persons import Person
11 #from PLC.Ilinks import Ilink
12
13 from PLC.Accessors.Factory import define_accessors, admin_roles, all_roles, tech_roles
14
15 import sys
16 current_module = sys.modules[__name__]
17
18 # NOTE.
19 # The 'Get' and 'Set' accessors defined here automagically create the corresponding TagType in the database
20 # for safety, some crucial tags are forced to be created at plc startup time, through the db-config.d mechanism
21 # You might wish to keep this roughly in sync with db-config.d/011-standard_tags
22 #
23
24
25 ### system slices - at least planetflow - still rely on 'vref'
26
27
28 # These following accessors are mostly of interest for implementing the 
29 # GetSliceFamily method, that takes into account the vref attribute, 
30 # as well as the 3 attributes below, and the PLC_FLAVOUR config category
31
32 ### slice vref 
33 define_accessors(current_module, Slice, "Vref", "vref", 
34                  "slice/config", "vserver reference image name",
35                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
36
37 # xxx the accessor factory should enforce the category and descriptions provided here.
38 # and BTW the tag should be created right away as far as possible, or at least when a Get is issued
39 # also note that the two 'arch' instances use here will end in the same unique TagType object,
40 # so you should make sure to use the same category/description for both 
41 define_accessors(current_module, Slice, "Arch", "arch", 
42                  "node/slice/config", "node arch or slivers arch",
43                  get_roles=all_roles, set_roles=["user"], expose_in_api=True)
44 define_accessors(current_module, Slice, "Pldistro", "pldistro",
45                  "node/slice/config", "PlanetLab distribution to use for node or slivers", 
46                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
47 define_accessors(current_module, Slice, "Fcdistro", "fcdistro",
48                  "node/slice/config", "Fedora or CentOS distribution to use for node or slivers", 
49                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
50
51 # Ditto for the GetNodeFlavour method
52 define_accessors(current_module, Node, "Arch", "arch",  
53                  "node/slice/config", "node arch or slivers arch",
54                  get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)
55 define_accessors(current_module, Node, "Pldistro", "pldistro",
56                  "node/slice/config", "PlanetLab distribution to use for node or slivers", 
57                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
58 define_accessors(current_module, Node, "Fcdistro", "fcdistro",
59                  "node/slice/config", "Fedora or CentOS distribution to use for node or slivers", 
60                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
61 # node deployment (alpha, beta, ...)
62 define_accessors(current_module, Node, "Deployment", "deployment",
63                  "node/operation", 'typically "alpha", "beta", or "production"',
64                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
65 # extension
66 define_accessors(current_module, Node, "Extensions", "extensions", 
67                  "node/config", "space-separated list of extensions to install",
68                  get_roles=all_roles, set_roles=["admin"],expose_in_api=True)
69 # access HRN - this is the ideal definition of roles, even if AddNodeTag cannot handle this 
70 define_accessors(current_module, Node, "Hrn","hrn",
71                  "node/sfa", "SFA human readable name",
72                  get_roles=all_roles, set_roles=["admin","pi","tech"], expose_in_api=True)
73
74 # test nodes perform their installation from an uncompressed bootstrapfs
75 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs", 
76                  "node/config", "use uncompressed bootstrapfs when set",
77                  get_roles=all_roles, set_roles=tech_roles)
78
79 # the tags considered when creating a boot CD
80 define_accessors(current_module, Node, "Serial", "serial",
81                  "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")
84 define_accessors(current_module, Node, "Kvariant", "kvariant",
85                  "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")
88 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
89                  "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium")
90
91 # interface 
92 # xxx - don't expose yet in api interface and slices dont know how to use that yet
93 define_accessors(current_module, Interface, "Ifname", "ifname", 
94                  "interface/config", "linux name",
95                  get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)
96 define_accessors(current_module, Interface, "Driver", "driver", 
97                  "interface/config", "driver name",
98                  get_roles=all_roles, set_roles=tech_roles)
99 define_accessors(current_module, Interface, "Alias", "alias", 
100                  "interface/config", "interface alias",
101                  get_roles=all_roles, set_roles=tech_roles)
102 define_accessors(current_module, Interface, "Backdoor", "backdoor",
103                  "interface/hidden", "For testing new settings",
104                  get_roles=all_roles, set_roles=admin_roles)
105