1 from PLC.Method import Method
2 from PLC.Auth import Auth
3 from PLC.Faults import *
4 from PLC.Parameter import *
5 from PLC.Slices import Slice, Slices
7 from PLC.Accessors.Accessors_standard import * # import slice accessors
8 from PLC.Accessors.Accessors_sliverauth import * # import slice accessors
10 class GetSliceFamily(Method):
12 Returns the slice vserver reference image that a given slice
13 should be based on. This depends on the global PLC settings in the
14 PLC_FLAVOUR area, optionnally overridden by any of the 'vref',
15 'arch', 'pldistro', 'fcdistro' tag if set on the slice.
18 roles = ['admin', 'user', 'node']
20 # don't support sliver-specific settings yet
23 Mixed(Slice.fields['slice_id'],
24 Slice.fields['name']),
27 returns = Parameter (str, "the slicefamily this slice should be based upon")
30 ### system slices - at least planetflow - still rely on 'vref'
32 def call(self, auth, slice_id_or_name):
33 # Get slice information
34 slices = Slices(self.api, [slice_id_or_name])
36 raise PLCInvalidArgument("No such slice %r"%slice_id_or_name)
38 slice_id = slice['slice_id']
40 # omf-control'ed slivers need the omf vserver reference image
41 # we used to issue SetSliceVref (self.api) (auth,slice_id,'omf')
42 # to avoid asking users to set both tags 'omf_control' and 'vref'
43 # however we can't use SetSliceVref here because a node is only allowed
44 # to set a sliver tag, not a slice tag
45 # and this somehow gets called from GetSlivers
46 # anyways it was a bad idea, let's have the UI do that instead
48 # the vref tag, if set, wins over pldistro
49 pldistro = GetSliceVref(self.api,self.caller).call(auth,slice_id) \
50 or GetSlicePldistro (self.api,self.caller).call(auth, slice_id) \
51 or self.api.config.PLC_FLAVOUR_SLICE_PLDISTRO
53 fcdistro = GetSliceFcdistro (self.api,self.caller).call(auth, slice_id) \
54 or self.api.config.PLC_FLAVOUR_SLICE_FCDISTRO
56 arch = GetSliceArch (self.api,self.caller).call(auth,slice_id) \
57 or self.api.config.PLC_FLAVOUR_SLICE_ARCH
59 # xxx would make sense to check the corresponding vserver rpms are available
60 # in all node-families yum repos (and yumgroups, btw)
61 return "%s-%s-%s"%(pldistro,fcdistro,arch)