revised accessor factory; tagtype gets created on Get... methods, and maintain a...
[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, all_roles, tech_roles
14
15 import sys
16 current_module = sys.modules[__name__]
17
18 # NOTE.
19 # most of these tag types are defined in MyPLC/db-config, so any details here in the 
20 # description/category area is unlikely to make it into the database
21 #
22
23
24 ### system slices - at least planetflow - still rely on 'vref'
25
26
27 # These following accessors are mostly of interest for implementing the 
28 # GetSliceFamily method, that takes into account the vref attribute, 
29 # as well as the 3 attributes below, and the PLC_FLAVOUR config category
30
31 ### slice vref 
32 define_accessors(current_module, Slice, "Vref", "vref", 
33                  "slice/config", "vserver reference image name",
34                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
35
36 # xxx the accessor factory should enforce the category and descriptions provided here.
37 # and BTW the tag should be created right away as far as possible, or at least when a Get is issued
38 # also note that the two 'arch' instances use here will end in the same unique TagType object,
39 # so you should make sure to use the same category/description for both 
40 define_accessors(current_module, Slice, "Arch", "arch", 
41                  "node/slice/config", "node arch or slivers arch",
42                  get_roles=all_roles, set_roles=["user"], expose_in_api=True)
43 define_accessors(current_module, Slice, "Pldistro", "pldistro",
44                  "node/slice/config", "PlanetLab distribution to use for node or slivers", 
45                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
46 define_accessors(current_module, Slice, "Fcdistro", "fcdistro",
47                  "node/slice/config", "Fedora or CentOS distribution to use for node or slivers", 
48                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
49
50 # Ditto for the GetNodeFlavour method
51 define_accessors(current_module, Node, "Arch", "arch",  
52                  "node/slice/config", "node arch or slivers arch",
53                  get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)
54 define_accessors(current_module, Node, "Pldistro", "pldistro",
55                  "node/slice/config", "PlanetLab distribution to use for node or slivers", 
56                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
57 define_accessors(current_module, Node, "Fcdistro", "fcdistro",
58                  "node/slice/config", "Fedora or CentOS distribution to use for node or slivers", 
59                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
60 # node deployment (alpha, beta, ...)
61 define_accessors(current_module, Node, "Deployment", "deployment",
62                  "node/operation", 'typically "alpha", "beta", or "production"',
63                  get_roles=all_roles, set_roles=["admin"], expose_in_api=True)
64 # extension
65 define_accessors(current_module, Node, "Extensions", "extensions", 
66                  "node/config", "space-separated list of extensions to install",
67                  get_roles=all_roles, set_roles=["admin"],expose_in_api=True)
68 # test nodes perform their installation from an uncompressed bootstrapfs
69 define_accessors(current_module, Node, "PlainBootstrapfs", "plain-bootstrapfs", 
70                  "node/config", "use uncompressed bootstrapfs when set",
71                  get_roles=all_roles, set_roles=tech_roles)
72
73 # the tags considered when creating a boot CD
74 define_accessors(current_module, Node, "Serial", "serial",
75                  "node/bootcd", "serial to use when creating the boot CD -- see GetBootMedium")
76 define_accessors(current_module, Node, "Cramfs", "cramfs",
77                  "node/bootcd", "boot CD to use cramfs if set -- see GetBootMedium")
78 define_accessors(current_module, Node, "Kvariant", "kvariant",
79                  "node/bootcd", "the variant to use for creating the boot CD -- see GetBootMedium")
80 define_accessors(current_module, Node, "Kargs", "kargs",
81                  "node/bootcd", "extra args to pass the kernel on the Boot CD -- see GetBootMedium")
82 define_accessors(current_module, Node, "NoHangcheck", "no-hangcheck",
83                  "node/bootcd", "disable hangcheck on the boot CD if set -- see GetBootMedium")
84
85 # interface 
86 # xxx - don't expose yet in api interface and slices dont know how to use that yet
87 define_accessors(current_module, Interface, "Ifname", "ifname", 
88                  "interface/config", "linux name",
89                  get_roles=all_roles, set_roles=tech_roles, expose_in_api=True)
90 define_accessors(current_module, Interface, "Driver", "driver", 
91                  "interface/config", "driver name",
92                  get_roles=all_roles, set_roles=tech_roles)
93 define_accessors(current_module, Interface, "Alias", "alias", 
94                  "interface/config", "interface alias",
95                  get_roles=all_roles, set_roles=tech_roles)
96
97 # site
98 define_accessors(current_module, Site, "Foo", "foo",
99                  "site/test", "some name",
100                  get_roles=all_roles, set_roles=all_roles, expose_in_api=True)