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 arch = GetSliceArch (self.api,self.caller).call(auth,slice_id)
41 if not arch: arch = self.api.config.PLC_FLAVOUR_SLICE_ARCH
43 pldistro = GetSlicePldistro (self.api,self.caller).call(auth, slice_id)
44 if not pldistro: pldistro = self.api.config.PLC_FLAVOUR_SLICE_PLDISTRO
46 fcdistro = GetSliceFcdistro (self.api,self.caller).call(auth, slice_id)
47 if not fcdistro: fcdistro = self.api.config.PLC_FLAVOUR_SLICE_FCDISTRO
49 # the vref tag, if set, wins over pldistro
50 vref = GetSliceVref (self.api,self.caller).call(auth,slice_id)
52 # omf-control'ed slivers need the omf vserver reference image
53 # we used to issue SetSliceVref (self.api) (auth,slice_id,'omf')
54 # to avoid asking users to set both tags 'omf_control' and 'vref'
55 # however we can't use SetSliceVref here because a node is only allowed
56 # to set a sliver tag, not a slice tag
57 # and this somehow gets called from GetSlivers
58 # anyways it was a bad idea, let's have the UI do that instead
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)