3 from PLC.Method import Method
4 from PLC.Auth import Auth
5 from PLC.Faults import *
6 from PLC.Parameter import *
7 from PLC.Slices import Slice, Slices
9 from PLC.Accessors.Accessors_standard import * # import slice accessors
10 from PLC.Accessors.Accessors_sliverauth import * # import slice accessors
12 class GetSliceFamily(Method):
14 Returns the slice vserver reference image that a given slice
15 should be based on. This depends on the global PLC settings in the
16 PLC_FLAVOUR area, optionnally overridden by any of the 'vref',
17 'arch', 'pldistro', 'fcdistro' tag if set on the slice.
20 roles = ['admin', 'user', 'node']
22 # don't support sliver-specific settings yet
25 Mixed(Slice.fields['slice_id'],
26 Slice.fields['name']),
29 returns = Parameter (str, "the slicefamily this slice should be based upon")
32 ### system slices - at least planetflow - still rely on 'vref'
34 def call(self, auth, slice_id_or_name):
35 # Get slice information
36 slices = Slices(self.api, [slice_id_or_name])
38 raise PLCInvalidArgument, "No such slice %r"%slice_id_or_name
40 slice_id = slice['slice_id']
42 arch = GetSliceArch (self.api).call(auth,slice_id)
43 if not arch: arch = self.api.config.PLC_FLAVOUR_SLICE_ARCH
45 pldistro = GetSlicePldistro (self.api).call(auth, slice_id)
46 if not pldistro: pldistro = self.api.config.PLC_FLAVOUR_SLICE_PLDISTRO
48 fcdistro = GetSliceFcdistro (self.api).call(auth, slice_id)
49 if not fcdistro: fcdistro = self.api.config.PLC_FLAVOUR_SLICE_FCDISTRO
51 # the vref tag, if set, wins over pldistro
52 vref = GetSliceVref (self.api).call(auth,slice_id)
54 # omf-control'ed slivers need the omf vserver reference image
55 # this is to avoid asking users to set both tags 'omf_control' and 'vref'
56 if not vref and GetSliceOmfControl(self.api).call(auth,slice_id):
57 SetSliceVref (self.api) (auth,slice_id,'omf')
60 # xxx would make sense to check the corresponding vserver rpms are available
61 # in all node-families yum repos (and yumgroups, btw)
63 return "%s-%s-%s"%(vref,fcdistro,arch)
65 return "%s-%s-%s"%(pldistro,fcdistro,arch)